Ata
Ata

Reputation: 393

Global Rotation

in GLScene we have three parameters (RollAngle, PitchAngle and TurnAngle) for rotation around local orientation. in the image below, how can I rotate cube around global orientation (orange axis)?

enter image description here

Upvotes: 7

Views: 2779

Answers (3)

Harriv
Harriv

Reputation: 6137

Maybe you could use "DummyCube" object as a parent. Then you can rotate first the cube inside dummy cube and then the DummyCube.

Upvotes: 3

Mikola
Mikola

Reputation: 9326

You would need to convert the axis angle rotation to Euler angles. Here is a link explaining this process in some detail with code:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToEuler/index.htm

From the article:

yaw   = atan2(y * sin(angle)- x * z * (1 - cos(angle)) 
                , 1 - (y2 + z2 ) * (1 - cos(angle)))   

pitch = asin(x * y * (1 - cos(angle)) + z * sin(angle))   

roll  = atan2(x * sin(angle)-y * z * (1 - cos(angle)) 
             , 1 - (x2 + z2) * (1 - cos(angle)))

EDIT: Renamed the variables to be consistent with the pitch, yaw, roll naming convention.

Upvotes: 7

dthorpe
dthorpe

Reputation: 36082

This is a dirty cheat, but if the object is at the origin (0,0,0) and there is only one object in the scene, you could swing the camera (and light source) around the object instead of rotating the object.

Upvotes: 1

Related Questions