Synopsis

PDX_MSGT gdx_GetAxisAngleFromMatrix(long option, GDX_MATRIX matrix, MTH_3DVEC axis, double *angle, MTH_3DPNT point)

Purpose

Conversion Matrix to Axis Angle

Description

A 3x3 matrix has 9 numbers therefore it contains replicated information, so there are many ways to derive the rotation from the numbers, here is a possible conversion:

angle = acos(( m00 + m11 + m22 - 1)/2) x = (m21 - m12)/sqrt((m21 - m12)2+(m02 - m20)2+(m10 - m01)2) y = (m02 - m20)/sqrt((m21 - m12)2+(m02 - m20)2+(m10 - m01)2) z = (m10 - m01)/sqrt((m21 - m12)2+(m02 - m20)2+(m10 - m01)2)

There are two singularities at angle = 0 and angle = 180, these cases the above formula may not work so we have to test for these cases separately. At 0 the axis is arbitrary (any axis will produce the same result), at 180 the axis is still relevant so we have to calculate it.

Input

option

Options (not used)

matrix

GDX matrix to convert

Output

axis

Calculated axis

angle

Calculated angle

point

Translation point

Return

GDX_NOERR or error