Page 1 of 1

Can any one solve this problem?

Posted: Fri May 28, 2004 9:36 pm
by Awesomator
Rotations can take place in different spaces. Ie: object-, World- space.
If i rotate an object it rotates it arround its object-space axis. What happens if i want to rotate an object on world-space axis?

Can any one help give me a solution that will rotate a object in world space by acting on its object space Roll, Pitch and Yaw?

Ill try and explain better if anyones confused. I cant think yet of how to do this!

Posted: Fri May 28, 2004 10:12 pm
by fweil
...,

Not sure it will be a one shot answer : the following code sample shows how to transform step by step a X, Y, Z point in a XR, YR, ZR resulting point after rotating it according to the given angle around the given axis.

You may use such transform code in procedures to apply transformations on a parametric 3D point.

This will rotate a given point around a given axis, and by combination around all axis.

Then, if you want to apply the rotation to a set of points using a given rotation center, you have to apply Sin / Cos functions to the distance from each point to a C(CX, CY, CZ) point. That is to say each x, y, z is to be changed to (cx - x), (cy - y) and (cz -z).

So if you miss a rotate function to apply on a set of points, vectors or anything, you will have to calculate points coordinates by yourself using such a stuff.

It can look tricky to do, but it generally calculates fast and gives nice rendering.

;
; Rotate X
;
XR = X
YR = Cos(angle_x) * Y - Sin(angle_x) * Z
ZR = Sin(angle_x) * Y + Cos(angle_x) * Z

;
; Rotate Y
;
XR = Cos(angle_y) * X + Sin(angle_y) * Z
YR = Y
ZR = -Sin(angle_y) * X + Cos(angle_y) * Z

;
; Rotate Z
;
XR = Cos(angle_z) * X - Sin(angle_z) * Y
YR = Sin(angle_z) * X + Cos(angle_z) * Y
ZR = Z

Posted: Sat May 29, 2004 3:46 pm
by Awesomator
I think my post was a little confusing maby! I'll tryn explain it again (better!).

A rotation applyed to a model will act upon its object space axis. How can i emulate it being rotated around the world space axis but only by applying any rotations to the object space axis when i know its current roll, pitch, yaw?

Damn :x ! I just cant explain it clearly! :idea: maby ill have to come back with some illustrations.

Posted: Sat May 29, 2004 3:52 pm
by Awesomator
btw, fweil-
that rotation system's realy cool huh. Iv used it before when i was experementing with software rendering.

I optimised it by setting a rotation space function that calculated and stored the Sin and Cos of the Roll, Pich and Yaw. -
Then when i needed to transform a point i just used the precalculated values.

:wink: Just in case anyone caired. thanks tho

Posted: Wed Jun 09, 2004 8:31 pm
by The seperator
You mean you want to turn an object around a turning object,... ?

Else I dont't know what you mean (smoked to much :P ).

Posted: Wed Jun 09, 2004 10:45 pm
by MadMax
Awesomator:
I think I know what you mean, if what you want is to rotate your object around a given point in the world. I have just been working on that. I'll be posting some code shortly (I'm very busy ATM, but by the end of the month I should have time)