## [Newton 2.0] Simple formula

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

### [Newton 2.0] Simple formula

Hi,

it's me again but this time, I do not wanna ask you about the custommultibody vehicle.
I just wanna know a simple formula :

How to determine the main axis (direction) of a 3D body out of the matrix that newton gives us. This direction must also be relative to something, but how to calculate it ?

Thanks in advance for taking time to answer to this simple newbie 3D question.
frankk

Posts: 32
Joined: Thu Oct 09, 2008 2:40 pm

### Re: [Newton 2.0] Simple formula

In other words, how to get the yaw, pitch and roll ?
frankk

Posts: 32
Joined: Thu Oct 09, 2008 2:40 pm

### Re: [Newton 2.0] Simple formula

That depend, what do you need it for?
Julio Jerez
Moderator

Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: [Newton 2.0] Simple formula

Perhaps NewtonGetEulerAngle is what you need.
Help improving the Newton Game Dynamics WIKI

JernejL

Posts: 1531
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

### Re: [Newton 2.0] Simple formula

If you need it from the matrix you can do it like this.
I don't have test it with all situation but working good for me.

Code: Select all
`function GetMatrixTurnAngle(mat: Tmatrix): single;begin  result :=radtodeg(-arctan2(-mat[2,0], mat[0,0]));end;function GetMatrixPitchAngle(mat: Tmatrix): single;begin  result :=radtodeg(-arctan2(-mat[1,2], mat[1,1]));end;function GetMatrixRollAngle(mat: Tmatrix): single;begin  result :=radtodeg(-arcsin(mat[1,0]));end;`
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos: