# Help with rotation math

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

## Recommended Posts

I'm wondering if someone can check my logic/math for a rotation. I have a 3D object, that consists of other 3D objects. For simplicity lets just use a Rubik's Cube as an example. If I rotate the entire cube, all of the cubes that make up the model must also rotate, and translate. I understand how to calculate the position of each of the 3D objects 'cubes' as a rotation of the entire model occurs, however I'm not sure if I'm doing the rotation math correctly. I'm doing something like this:
BlockRot = CubeRot * BlockRot;

Where all rotations are matrices, and BlockRot refers to a single block on the entire Rubik's cube, and CubeRot is the rotation of the entire Rubik's cube model. EDIT: I should mention that BlockRot is the Block's local rotation, which does NOT include any rotation of the entire cube itself. [Edited by - lordikon on January 19, 2009 7:33:32 PM]

Bump, no one?

##### Share on other sites
It looks to me like you've understood the concept of having different reference coordinate systems. However you'll have to not only transform the individual rotations of the blocks but the whole transform (rotation AND translation). Let me try to explain. If you want to rotate a number of blocks as a unit (as you do) you'll need to calculate a transform for each block which places (rotation / translation) it in a the cubes coordinate system. So each block would have a transformation in cubespace (I just invented that word!). However when you want to render or find the correct worldspace transformation you'll have to transform all the blocks using the reference coordinate system you've defined the blocks transforms in. I'm sorry if the explanation is not that clear - but feel free to ask again!

So what you need to do is calculate a 4x4 transform matrix for each of your blocks (how you go about this really depends on what system / math conventions you're using (row / column major, left-handed / right-handed etc). When you've done that you'll need an equivilent 4x4 transform matrix for the cube as a whole whos purpose it is to place the cube in worldspace (or some other reference space). So to get the correct worldspace transform for each of the blocks in the cube you would have to transform the objectspace coordinates using the blocks 4x4 transform and the cubes 4x4 transform (multiply it all together and use this matrix to transform the indiviual vertices that makes up the block). Mind you that the multiply direction matters (blockT * cubeT != cubeT * blockT).

Wow what a horrid mess I've made of this :) I would recommend buying a book about this stuff as there's a lot of subtle details I've skipped because I'm lazy!

1. 1
Rutin
30
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632961
• Total Posts
3009494
• ### Who's Online (See full list)

There are no registered users currently online

×