# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: getEuler has unreachable codePosted: Wed May 30, 2007 12:41 am

Joined: Wed May 30, 2007 12:36 am
Posts: 3
When converting a 3x3 matrix to its Euler angles, I came across the following code in btMatrix3x3.h:

Code:
void getEuler(btScalar& yaw, btScalar& pitch, btScalar& roll) const
{
pitch = btScalar(btAsin(-m_el[2][0]));
if (pitch < SIMD_2_PI)
{
if (pitch > SIMD_2_PI)
{
yaw = btScalar(btAtan2(m_el[1][0], m_el[0][0]));
roll = btScalar(btAtan2(m_el[2][1], m_el[2][2]));
}
else
{
yaw = btScalar(-btAtan2(-m_el[0][1], m_el[0][2]));
roll = btScalar(0.0);
}
}
else
{
yaw = btScalar(btAtan2(-m_el[0][1], m_el[0][2]));
roll = btScalar(0.0);
}
}

The first if doesn't make sense- asin should never return a value higher than 2pi. The second if statement makes even less sense. How is it even possible to reach that code (only reachable if pitch < 2 pi and greater than 2 pi.

I am in need of this function and it seems to be returning incorrect values. Any insights?

[/code]

Top

 Post subject: Posted: Wed May 30, 2007 3:09 am

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3746
Location: California, USA
This was an un-used method and something must have gone wrong when porting the original code. This is the updated version, is checked into svn so should go into next version.

Can you check it?
Thanks for the feedback,
Erwin

Code:
void getEuler(btScalar& yaw, btScalar& pitch, btScalar& roll) const
{

if (btScalar(m_el[1].z()) < btScalar(1))
{
if (btScalar(m_el[1].z()) > -btScalar(1))
{
yaw = btScalar(btAtan2(m_el[1].x(), m_el[0].x()));
pitch = btScalar(btAsin(-m_el[1].y()));
roll = btScalar(btAtan2(m_el[2].y(), m_el[2].z()));
}
else
{
yaw = btScalar(-btAtan2(-m_el[0].y(), m_el[0].z()));
pitch = SIMD_HALF_PI;
roll = btScalar(0.0);
}
}
else
{
yaw = btScalar(btAtan2(-m_el[0].y(), m_el[0].z()));
pitch = -SIMD_HALF_PI;
roll = btScalar(0.0);
}
}

Top

 Post subject: Posted: Thu May 31, 2007 4:48 pm

Joined: Wed May 30, 2007 12:36 am
Posts: 3
Yeah it looks like it's working.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities