Main Content

fitCollisionCapsule

Fit collision capsule around collision geometry

Since R2022b

    Description

    [collCapsule,fitInfo] = fitCollisionCapsule(geom) fits a collision capsule collCapsule around a collision geometry geom.

    example

    Examples

    collapse all

    Create a box with a length, width, and height of 1 meter and fit a collision capsule on it.

    box = collisionBox(1,1,1);
    show(box);
    hold on
    [collcaps,fitinfo]= fitCollisionCapsule(box);

    Visualize the new collision capsule on top of the box and set the alphas of the capsule to a low value so that the box is visible.

    [~,capvis] = show(collcaps);
    capvis.FaceAlpha=0.4;
    xlim auto
    ylim auto
    zlim auto

    Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 2 objects of type patch.

    Input Arguments

    collapse all

    Collision geometry to fit capsule onto, specified as either a collisionBox, collisionSphere, collisionCylinder, or collisionMesh object.

    Output Arguments

    collapse all

    Collision capsule of the collision geometry, returned as a collisionCapsule object.

    Fit information of the collision capsule, returned as a structure. The structure contains the Residual field, returned as an N-element vector, where N is the total number of points of the collision geometry. Each element of the vector specifies the residual of a point of the collision geometry as:

    |(ocglcc)|+rcc

    where:

    • ocg is the origin of the fitted collision object.

    • lcc is the closest point of the central line of the collision capsule to ocg.

    • rcc is the radius of the collision capsule.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2022b