# distance

## Description

## Input Arguments

`manipSS`

— Manipulator state space

`manipulatorStateSpace`

object

Manipulator state space, specified as a `manipulatorStateSpace`

object, which is a subclass of `nav.StateSpace`

(Navigation Toolbox).

`state1`

— Initial state position

*n*-element row vector | *m*-by-*n* matrix

Initial state position, specified as an*n*-element row vector or
*m*-by-*n* matrix. *n* is the
dimension of the state space specified in the `NumStateVariables`

property of `manipSS`

. *m* is the number of initial
state positions.

The sizes of `state1`

and `state2`

determine
the size of the `dist`

output:

**State Vectors and Distances**

`state1 Size` | `state2 Size` | `dist Size` |
---|---|---|

n-element row vector | n-element row vector | scalar |

n-element row vector | m-by-n matrix | m-element column vector |

m-by-n matrix | n-element row vector | m-element column vector |

m-by-n matrix | m-by-n matrix | m-element column vector |

`state2`

— Final state position

*n*-element vector | *m*-by-*n* matrix of row vectors

Final state position, specified as a *n*-element row vector or
*m*-by-*n* matrix. *n* is the
dimension of the state space specified in the `NumStateVariables`

property of `manipSS`

. *m* is the number of initial
state positions.

The sizes of `state1`

and `state2`

determine
the size of the `dist`

output:

**State Vectors and Distances**

`state1 Size` | `state2 Size` | `dist Size` |
---|---|---|

n-element row vector | n-element row vector | scalar |

n-element row vector | m-by-n matrix | m-element column vector |

m-by-n matrix | n-element row vector | m-element column vector |

m-by-n matrix | m-by-n matrix | m-element column vector |

## Output Arguments

`dist`

— Distance between two states

numeric scalar | *m*-element column vector

Distance between two states, returned as a numeric scalar or
*m*-element column vector. This distance calculation is the main
component in evaluating the costs of paths. For prismatic joints, the distance between
two states is the Euclidean norm of the difference between the state vectors. For
revolute joints with infinite bounds, the difference in joint values is calculated using
`angdiff`

.

For revolute joints, distances measure joint differences in radians. For prismatic joints, distances measure displacement in meters.

The sizes of `state1`

and `state2`

determine
the size of output `dist`

:

**State Vectors and Distances**

`state1 Size` | `state2 Size` | `dist Size` |
---|---|---|

n-element row vector | n-element row vector | scalar |

n-element row vector | m-by-n matrix | m-element column vector |

m-by-n matrix | n-element row vector | m-element column vector |

m-by-n matrix | m-by-n matrix | m-element column vector |

## Version History

**Introduced in R2021b**

## See Also

`nav.StateSpace`

(Navigation Toolbox) | `nav.StateValidator`

(Navigation Toolbox) | `stateSpaceSE2`

(Navigation Toolbox) | `stateSpaceDubins`

(Navigation Toolbox) | `stateSpaceReedsShepp`

(Navigation Toolbox)

### Topics

- Create Custom State Space for Path Planning (Navigation Toolbox)

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)