Main Content

dist

Calculate distance between transformations

    Description

    distance = dist(transformationA,transformationB) returns the distance distance between the poses represented by transformation transformationA and transformation transformationB.

    For the homogeneous transformation objects se2, and se3, the dist function calculates translational and rotational distance independently and combines them in a weighted sum. Translational distance is the Euclidean distance, and rotational distance is the angular difference between the rotation quaternions of transformationA and transformationB.

    For rotational transformation objects so2, and so3, the dist function calculates the rotational distance as the angular difference between the rotation quaternions of transformationA and transformationB.

    distance = dist(transformationA,transformationB,weights) specifies the weights weights for the translational and rotational distances for calculating the weighted sum of two homogeneous transformations. The weights do not apply when calculating the distance between two rotation transformations.

    Input Arguments

    collapse all

    First transformation, specified as an se2, se3, so2, or so3 object, or as an M-element array of transformation objects. M is the total number of transformations.

    If you specify transformationA as an array, then each element must be of the same type, and transformationB must either be a scalar transformation object of the same type as transformationA or an array of the same type and size as transformationA.

    First transformation, specified as an se2, se3, so2, or so3 object, or as an M-element array of transformation objects. M is the total number of transformations.

    If you specify transformationB as an array, then each element must be of the same type, and transformationA must either be a scalar transformation object of the same type as transformationB or an array of the same type and size as transformationB.

    Weights of the translation and rotation in the distance sum, specified as a two-element row vector in the form [WeightXYZ WeightQ]. WeightXYZ is the translational weight and WeightQ is the rotational weight. Both weights must be nonnegative numeric scalars.

    The do not affect the distance calculation when transformationA and transformationB are so2 or so3 objects.

    Data Types: single | double

    Output Arguments

    collapse all

    Distance between transformations, returned as a nonnegative numeric scalar. The distance calculate changes depending on the transformation object type of transformationA and transformationB:

    • se2 and se3 — The dist function calculates translational and rotational distance independently and combines them in a weighted sum specified by the weights argument. The translational distance is the Euclidean distance between transformationA and transformationB. The rotational distance is the angular difference between the rotations of transformationA and transformationB.

    • so2 and so3 — The dist function calculates the rotational distance as the angular difference between the rotations of transformationA and transformationB.

    To calculate the rotational distance, the dist function converts the rotation matrix of transformationA and transformationB into quaternion objects and uses the quaternion dist function to calculate the angular distance.

    Version History

    Introduced in R2022b

    See Also

    Functions

    Objects