Jump to content
• ### What is your GameDev Story?

• Advertisement

Public Group

# local and global rotations

This topic is 4508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

hi guys. say i have a matrix for an object, rotated to however i want it. now if i wanted to apply a rotation in the worlds x-axis, how would i go about it? as multiplying it by a rotation matrix in the x-axis rotates it in its local axis.

#### Share this post

##### Share on other sites
Advertisement
Before applying the rotation matrix, add the object's center vector coords to it's points coords(or don't subtract the same,this is the opposite operation if you want to go from global to local)

#### Share this post

##### Share on other sites
im not sure i understand, the objects centre vector coords are the objects local axis? could be because its half 2 in the morning...;)

#### Share this post

##### Share on other sites
1,0,0 would be the 'world' x-axis (this is usually the case, it could be different, but I doubt it). The 'local' x-axis of the object is the unit-vector that points to the 'right' of the object given it's current rotation, which could very well be the same as the world x-axis (depending on the local rotation). So if the local x-axis of the object is pointing in the same direction as the world z-axis (0,0,1), then rotating the object around the world x-axis would rotate the object about it's local z-axis.

#### Share this post

##### Share on other sites
Given a rotation matrix, multiplying it on one side by a matrix representing a rotation about a cardinal axis will have the effect of a global axis rotation, while multiplying it on the other side by the same matrix will have the effect of the corresponding local axis rotation. Which side is which depends on whether you're using row or column vector notation convention, but in your case it sounds like you should just be able to multiply on the other side and get the results you're after.

#### Share this post

##### Share on other sites
Quote:
 Original post by Rajveerim not sure i understand, the objects centre vector coords are the objects local axis? could be because its half 2 in the morning...;)

the object's centre vector coords,are the coordinates the other points of the object are defined on,as the offset of between their global coordinates and this center coordinates.

you can express object's with two ways:

[1]defining the offset from the LOCAL CENTER for its point

for example we have a triangle :
with points:

(0,0,0)
(0,1,0)
(1,1,0)

located at (4,2,-6) <- this coords you need to add to the points' coords if you use that system

[2]keeping the global offset and subtracting the center coordinates from it when you need to do a local transformation,like scaling or rotation by local center

the same triangle as above:

(4,2,-6)
(4,3,-6) <- this coords you want
(5,3,-6)

located at (4,2,-6)

#### Share this post

##### Share on other sites
Quote:
 Original post by jykGiven a rotation matrix, multiplying it on one side by a matrix representing a rotation about a cardinal axis will have the effect of a global axis rotation, while multiplying it on the other side by the same matrix will have the effect of the corresponding local axis rotation. Which side is which depends on whether you're using row or column vector notation convention, but in your case it sounds like you should just be able to multiply on the other side and get the results you're after.

thanks all for your replies, im not sure if i was expressing my problem properly (was early in the morning!) but i think jyk answered it for me :)

so if i understand correctly, if i have an objects rotation matrix A and i have a new rotation matrix B to multiply it by, A . B will rotate the object in the objects local axis corresponding to A, whereas B . A will rotate the object with the "global axis". it seems so obvious, wonder why i didnt think of it! cheers everybody :)

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 15
• 9
• 11
• 9
• 9
• Advertisement
• ### Forum Statistics

• Total Topics
634133
• Total Posts
3015747
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!