# dcm2rod

Convert direction cosine matrix to Euler-Rodrigues vector

## Syntax

``R = dcm2rod(dcm)``
``R = dcm2rod(dcm,action)``
``R = dcm2rod(dcm,action,tolerance)``

## Description

example

````R = dcm2rod(dcm)` function calculates the Euler-Rodrigues vector (`R`) from the direction cosine matrix. This function applies only to direction cosine matrices that are orthogonal with determinant +1.`R = dcm2rod(dcm,action)` performs `action` if the direction cosine matrix is invalid (not orthogonal).`R = dcm2rod(dcm,action,tolerance)` uses a `tolerance` level to evaluate if the direction cosine matrix, `n`, is valid (orthogonal). ```

## Examples

collapse all

Determine the Rodrigues vector from the direction cosine matrix.

```DCM = [0.433 0.75 0.5;-0.25 -0.433 0.866;0.866 -0.5 0.0]; r = dcm2rod(DCM)```
```r = 1.3660 0.3660 1.0000 ```

Determine the Rodrigues vector from the direction cosine matrix validated within tolerance.

```DCM = [0.433 0.75 0.5;-0.25 -0.433 0.866;0.866 -0.5 0.0]; r = dcm2rod(DCM,'Warning',0.1) ```
```r = 1.3660 0.3660 1.0000```

## Input Arguments

collapse all

3-by-3-by-M containing M direction cosine matrices.

Data Types: `double`

Function behavior when direction cosine matrix is invalid (not orthogonal).

• Warning — Displays warning and indicates that the direction cosine matrix is invalid.

• Error — Displays error and indicates that the direction cosine matrix is invalid.

• None — Does not display warning or error (default).

Data Types: `char` | `string`

Tolerance of direction cosine matrix validity, specified as a scalar. The function considers the direction cosine matrix valid if these conditions are true:

• The transpose of the direction cosine matrix times itself equals `1` within the specified tolerance (`transpose(n)*n == 1±tolerance`)

• The determinant of the direction cosine matrix equals `1` within the specified tolerance (`det(n) == 1±tolerance`).

Data Types: `double`

## Output Arguments

collapse all

M-by-3 matrix containing M Rodrigues vectors.

Data Types: `double`

## Algorithms

An Euler-Rodrigues vector $\stackrel{⇀}{b}$ represents a rotation by integrating a direction cosine of a rotation axis with the tangent of half the rotation angle as follows:

`$\stackrel{\to }{b}=\left[\begin{array}{ccc}{b}_{x}& {b}_{y}& {b}_{z}\end{array}\right]$`

where:

`$\begin{array}{l}{b}_{x}=\mathrm{tan}\left(\frac{1}{2}\theta \right){s}_{x},\\ {b}_{y}=\mathrm{tan}\left(\frac{1}{2}\theta \right){s}_{y},\\ {b}_{z}=\mathrm{tan}\left(\frac{1}{2}\theta \right){s}_{z}\end{array}$`

are the Rodrigues parameters. Vector $\stackrel{⇀}{s}$ represents a unit vector around which the rotation is performed. Due to the tangent, the rotation vector is indeterminate when the rotation angle equals ±pi radians or ±180 deg. Values can be negative or positive.

## References

[1] Dai, J.S. "Euler-Rodrigues formula variations, quaternion conjugation and intrinsic connections." Mechanism and Machine Theory, 92, 144-152. Elsevier, 2015.