Hi.

I have a very specific problem. Explaining exactly what Im doing is most likely redundent so Im just going to try and explain what I need as best as possible using a simple example.

Im applying a eular angle to a vector in 3D space by first rotating the vector around the x-axes, then y, then z.

Its a givin that for this particular eular angle the same end result can be achived by only rotating around the z axis by a certian amount. For this givin Eualr angle how would I calculate the neccesary rotation around the Z axis.

Thnx in Advance!

**0**

# Eular angle question

Started by Wilhelm van Huyssteen, Apr 05 2012 07:55 PM

5 replies to this topic

Sponsor:

###
#2
Members - Reputation: **100**

Posted 05 April 2012 - 10:00 PM

I could be wrong but it seems like what you are looking for is a quaternion. You can't represent any rotated vector by only rotating it around the Z-Axis. A quaternion is simply a vector in space that can represent your rotation and then an amount of rotation around that axis. But constraining the rotation to only rotating around the Z-Axis will limit your degrees of freedom. Hopefully this is what you were trying to explain. If not, correct me and hopefully I can help.

###
#3
Members - Reputation: **1010**

Posted 06 April 2012 - 02:27 AM

Yes rotating around only 1 axis will limit the degrees of freedom but thats fine. As i tried to explain the input eular angle will always fall within the allowed range as a givin. Heres some actual numbers

rotating a point in 3D space with eular angle

x: 180

y: 180

z: 50

in the order of x,y and then z will have the same effect on the point as just rotating around the z-axis by 130 degrees

so i want to know how i can get from

x: 180

y: 180

z: 50

to

x: 0

y: 0

z: 130

rotating a point in 3D space with eular angle

x: 180

y: 180

z: 50

in the order of x,y and then z will have the same effect on the point as just rotating around the z-axis by 130 degrees

so i want to know how i can get from

x: 180

y: 180

z: 50

to

x: 0

y: 0

z: 130

###
#4
Crossbones+ - Reputation: **4589**

Posted 06 April 2012 - 03:57 AM

When using column vector notation, the Euler rotation is formulated as

which you want to equal a single z axis rotation, so that

This implies 9 equations for a single variable (namely the argument angle to

cos( z' ) = a

cos( z' ) = b

sin( z' ) = c

-sin( z' ) = d

where the numerical values of a and b as well as those of c and -d are obviously the same; further a and c need to differ in a phase shift of 90 degree.

When you use the arccos or arcsin function for solving, then you get a result that covers a half circle only. So you need to take 2 of the above functions into account. One way to do this is to choose e.g.

tan( z' ) = sin( z' ) / cos( z' ) = a / c

and hence

z' = arctan( a / c )

in principle. However, this formula still has problems, because it (1.) is vulnerable against c==0 and (2.) only 2 of the 4 quadrants can be identified (i.e. the same problem as those above).

Fortunately, most programming languages provide a variant of arctan that internally deals with this problem. This function is usually named atan2. So try

z' = atan2( c, a )

where a and c are picked from the combined Euler rotation matrix.

FYI: The above does something like looking at the problem in the 2D space given by the x/y plane. It sees a vector (a c)

**R**_{z}***R**_{y}***R**_{x}=:**R**_{E}which you want to equal a single z axis rotation, so that

**R**_{E}=**R**_{z}'This implies 9 equations for a single variable (namely the argument angle to

**R**_{z}'), what obviously can be solved in special situations only. When such a situation is actually given, then you have 4 equations likecos( z' ) = a

cos( z' ) = b

sin( z' ) = c

-sin( z' ) = d

where the numerical values of a and b as well as those of c and -d are obviously the same; further a and c need to differ in a phase shift of 90 degree.

When you use the arccos or arcsin function for solving, then you get a result that covers a half circle only. So you need to take 2 of the above functions into account. One way to do this is to choose e.g.

tan( z' ) = sin( z' ) / cos( z' ) = a / c

and hence

z' = arctan( a / c )

in principle. However, this formula still has problems, because it (1.) is vulnerable against c==0 and (2.) only 2 of the 4 quadrants can be identified (i.e. the same problem as those above).

Fortunately, most programming languages provide a variant of arctan that internally deals with this problem. This function is usually named atan2. So try

z' = atan2( c, a )

where a and c are picked from the combined Euler rotation matrix.

FYI: The above does something like looking at the problem in the 2D space given by the x/y plane. It sees a vector (a c)

^{t}and computes the angle that is between the principal x axis and the vector. You can find several discussions of this in this forum if you search for e.g. "atan2".###
#6
Members - Reputation: **841**

Posted 06 April 2012 - 06:38 AM

I once wrote some examples about generic Euler angle conversions:

http://khayyam.kapli...-matrix-to.html

http://khayyam.kapli...ler-angles.html

These allow you:

http://khayyam.kapli...-matrix-to.html

http://khayyam.kapli...ler-angles.html

These allow you:

- Convert rotation matrix to arbitrarily ordered Euler angles (useful for animations)
- Pick the smallest set of angles from alternate rotation variants (that is what you needed)
- Pick the set of angles from alternate rotation variants that is closest to some previous set (useful for animations)
- Should be gimbal-lock safe

Lauris Kaplinski

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya

Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya

Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/