Main Content

convertToCollisionMesh

Convert collision primitive geometry into collision mesh geometry

Since R2022a

    Description

    collisionMesh = convertToCollisionMesh(collisionObj) converts a collision primitive geometry, collisionObj, to a convex mesh collision geometry, collisionMesh, which retains the pose of collisionObj.

    Note

    Because converting a collision primitive to a collision mesh discretizes the underlying primitive, the converted mesh can return a different checkCollision result than the primitive equivalent.

    example

    Examples

    collapse all

    Create and visualize a box as a collision geometry object.

    box = collisionBox(2,3,4)
    box = 
      collisionBox with properties:
    
           X: 2
           Y: 3
           Z: 4
        Pose: [4x4 double]
    
    
    show(box);

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

    Convert the collision box to a mesh. Visualize the mesh.

    mesh = convertToCollisionMesh(box)
    mesh = 
      collisionMesh with properties:
    
        Vertices: [8x3 double]
            Pose: [4x4 double]
    
    
    show(mesh);

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

    Input Arguments

    collapse all

    Collision geometry object, specified as a collisionBox, collisionSphere, collisionCylinder, or collisionCapsule object. The function converts this object into a collision mesh.

    Output Arguments

    collapse all

    Collision mesh, returned as a collisionMesh object. This object is the mesh equivalent of the specified collision geometry object.

    Extended Capabilities

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

    Version History

    Introduced in R2022a