# Rotation Matrix to VRML Rotation

Convert rotation matrix into representation used in virtual world

## Library

Simulink® 3D Animation™

## Description

Takes an input of a rotation matrix and outputs the axis/angle rotation representation used for defining rotations in a virtual world. The rotation matrix can be either a 9-element column vector or a 3-by-3 matrix defined columnwise.

 Note:   This block works with VRML and X3D virtual worlds.

## Parameters

Maximum value to treat input value as zero — The input is considered to be zero if it is equal to or lower than this value.

### Rotation Matrix

A representation of a three-dimensional spherical rotation as a 3-by-3 real, orthogonal matrix R: RTR = RRT = I, where I is the 3-by-3 identity and RT is the transpose of R.

`$R=\left(\begin{array}{ccc}{R}_{11}& {R}_{12}& {R}_{13}\\ {R}_{21}& {R}_{22}& {R}_{23}\\ {R}_{31}& {R}_{32}& {R}_{33}\end{array}\right)=\left(\begin{array}{ccc}{R}_{xx}& {R}_{xy}& {R}_{xz}\\ {R}_{yx}& {R}_{yy}& {R}_{yz}\\ {R}_{zx}& {R}_{zy}& {R}_{zz}\end{array}\right)$`

In general, R requires three independent angles to specify the rotation fully. There are many ways to represent the three independent angles. Here are two:

• You can form three independent rotation matrices R1, R2, R3, each representing a single independent rotation. Then compose the full rotation matrix R with respect to fixed coordinate axes as a product of these three: R = R3*R2*R1. The three angles are Euler angles.

• You can represent R in terms of an axis-angle rotation n = (nx,ny,nz) and θ with n*n = 1. The three independent angles are θ and the two needed to orient n. Form the antisymmetric matrix:

`$\stackrel{^}{J}=\left(\begin{array}{ccc}0& -{n}_{z}& {n}_{y}\\ {n}_{z}& 0& -{n}_{x}\\ -{n}_{y}& {n}_{x}& 0\end{array}\right)$`

Then Rodrigues' formula simplifies R:

`$R=\mathrm{exp}\left(\theta \stackrel{^}{J}\right)=I+\stackrel{^}{J}\mathrm{sin}\theta +{\stackrel{^}{J}}^{2}\left(1-\mathrm{cos}\theta \right)$`
Was this topic helpful?

Get trial now