Can any one solve this problem?

Advanced game related topics
Awesomator
New User
New User
Posts: 5
Joined: Fri May 28, 2004 9:10 pm

Can any one solve this problem?

Post 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!
Intuition is the holy grail!
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Awesomator
New User
New User
Posts: 5
Joined: Fri May 28, 2004 9:10 pm

Post 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.
Intuition is the holy grail!
Awesomator
New User
New User
Posts: 5
Joined: Fri May 28, 2004 9:10 pm

Post 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
Intuition is the holy grail!
The seperator
User
User
Posts: 17
Joined: Sun Apr 25, 2004 9:12 pm
Location: Europe, Belgium

Post 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 ).
MadMax
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Oct 06, 2003 11:56 am

Post 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)
Post Reply