Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2006-09-14 03:59:19

AnglesBloke
Guest

3d rotation problem. Probably something to do with Euler angles

x axis runs from west to east
y axis runs from south to north
z axis runs from ground to sky

angle a rotates around axis z
angle b rotates around axis y
angle c rotates around axis x

When rotating around the z axis, the other two axes (x and y) also spin round.
When rotating around the y axis, neither the z or x axes move.
When rotating around the x axis, the z axis remains where it is but the y axis tilts with the rotation.

so...

angle a moves the x and y axes.
angle b doesn't move any axes.
angle c moves the y axis.

What I want to do is rotate (in radians):
(angle a) 0.0  around the z axis,
(angle b) 0.3  around the y axis,
(angle c) PI/4 around the NEW x axis.

The problem is that when it comes to rotating around the x axis, angle c still rotates around the original x axis and not the 'NEW' tilted x axis I need.
I have solved the problem but my solution only works for the 90 degree (0, Pi/2, Pi, 1.5Pi) rotations around the x axis (angle c) combined with some rotation around axis y (angle b).
Here is my 'solution' for the 90 degree angles:

A = 0.0, B = 0.3, C = Pi/2 (Remember, this is around the 'new' tilted x axis);

a = (A - C) + (C * cos(C))
b = (C * sin(C)) + (B * cos(C))
c = C - (B * sin(C))

This gives:

a = -Pi/2
b = Pi/2
c = Pi/2 - B

As you can see even though I dont want any rotation on angle a, there is some but it is cancelled by b = Pi/2. This works when C = 0, or Pi/2, or Pi, or 1.5Pi. I arrived at this pretty much by trial and error so I don't understand how or why it works.

I've been looking at Euler angles to try and solve my problem but Im not sure what I should be trying to do, my brain can not handle multiple axes some of wich are moving and some aren't !!

I really would appreciate any help I can get with this, so here is the imminent question:

Any ideas ?

Thanks.

#2 2006-09-15 06:31:16

slfer100
Member
Registered: 2006-09-11
Posts: 106

Re: 3d rotation problem. Probably something to do with Euler angles

dunnofainttongueswearswearqahhhhhhhhhhhhhhhhhh what are u talking about


naver give up on the war of love unless if you want to! big_smile

Offline

#3 2006-09-15 12:02:01

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: 3d rotation problem. Probably something to do with Euler angles

Are you using some sort of 3D graphics library?  If so, what?


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#4 2006-09-16 02:44:00

mikau
Member
Registered: 2005-08-22
Posts: 1,504

Re: 3d rotation problem. Probably something to do with Euler angles

The way I did it in the 3d program I wrote for fun, was like this:

Say you want to rotate a point (a, b, c) on the xy axis.

You can perform the rotation in two ways, by using inverse trig or a trig identity.

You can first convert a point to polar form using inverse trig functions. Once its in polar form, you can add to or subtract from θ, and convert it back to rectangular form to rotate it.

Another way, you can see that after the angle is rotated, the angle of its polar form will be its original polar angle t plus the angle you rotated it.

So... the new y coordinate will be  r * sin (t + θ) and the new x coordinate will be r * cos ( t + θ ). Where r is the initial distance from the point you're rotating, and the center of rotation.
Using the trig identies sin (A + B) = sin A cos B + cos A sin B   and
cos (A + B) = cos A cos B - sin A sin B
we can now find the values of cos (t + θ) and sin (t + θ) by sines and cosines of t and θ, the sine and cosine of θ we can find easy since we know the angle. The sine and cosine of t, we can find without worrying about how much t is. The sine of t would be its vertical distance from the rotation point ((the difference of the y coordinates), divided by its direct distance from the rotation point (use the distance formula) the cosine of t would be its
horizontal distance from the rotation point (the difference of the x coordinates) divided by its direct distance from the rotation point. (again the distance formula)

I read that inverse trig functions can be very time consuming in computer programs. Which is why I used the second method, and it did run a lot faster.

But I believe matrices are the traditional method for doing anything in 3d graphics. world transform, rotation, perspective distortion, etc. I don't know how that could possibly be faster since matrice multiplications are so long, but whatever.

Last edited by mikau (2006-09-16 02:47:42)


A logarithm is just a misspelled algorithm.

Offline

#5 2006-09-16 08:16:55

AnglesBloke
Guest

Re: 3d rotation problem. Probably something to do with Euler angles

Hi, no not any graphics library, and not rotating a point around an axis.

What Im doing is writing a bit of software that generates map files for a game automatically, so you can build larger things out of smaller things without having to put all the bits in by hand.

In the map file are 3 coordinates that say where the center of the object is placed, and 3 rotation angles that say how the object is rotated. The problem is the rotations dont work as I expected.

I can get it working when only using 2 angles and no rotation on the third, when trying to add the third rotation the axis I need to rotate around doesnt exist anymore because one of the previous rotation has moved it.

Board footer

Powered by FluxBB