# matrix to euler (3d math primer book error?)

This topic is 4232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi, i use the book "3d math primer for graphics and game development". on page 184 there is an example for a function which converts a rotation matrix to eulers.
float sp = -m23;

...

if(sp > 0.9999) // gimbal lock check
{
// we are looking straight up or down
...
}
else
{
...
}
is this gimbal lock check correct? doesn't this only check for looking up? [Edited by - machinimist on May 16, 2007 7:54:19 AM]

##### Share on other sites
EDIT: I answered this question earlier but now I realise I was being stupid!

I don't have this book, but:

If 'sp' is a sin(x) term as seems likely, then you may be right about the 'if' statement not working as intended.

If 'sp' is a cos(x) term (e.g. 1 - cos(x)) then the 'if' statement is probably working as intended. But it would be silly to refer to cosine term as 'sp'...

I wouldn't like to say whether or not the function is correct without looking at it, so can you post the function or algorithm used, if it's fairly small?

[Edited by - tweduk on May 16, 2007 1:17:02 PM]

##### Share on other sites
i am pretty sure it should be (fabs(sp) > 0.9999). it's a mistake in the book. sp = sin(pitch).

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013612
×