Main Content

convertToCollisionMesh

Convert collision primitive geometry into collision mesh geometry

    Description

    example

    collisionMesh = convertToCollisionMesh(collisionObj) converts a collision geometry, collisionObj, to a convex mesh collision geometry, collisionMesh, which retains the pose of the 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.

    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 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 contains an object of type patch.

    Input Arguments

    collapse all

    Collision geometry object, specified as a collisionBox, collisionSphere, or collisionCylinder 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