#### Archived

This topic is now archived and is closed to further replies.

# Rotation around non-origin

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

## Recommended Posts

I''ve been trying to figure this question out for a few days now. I''m making a simple universe and I want to have the moon rotate around the earth. But with the D3DXMatrixRotationY() function, it rotates around the origin (I do believe). Do I have to translate to origin.x/y/z - position.x/y/z, rotate, and then translate back or can I do something else. Thanks in advance! /* I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition) */

##### Share on other sites
You might be able to use the position of the moon relative to the earth as an equation instead of using the matrices to change the position?? I don''t know how much math you have but if you use polar coords you can set it up with

r = radius from earth center to moon center

If the moon is moving horizontally relative to the world coords then you''d use z instead of y for the second coord. You could also set it up to have motion vectors like particle systems use. If you have taken Calculus you will surely understand those ideas better. If you want more detail about that just ask.

##### Share on other sites
To rotate an object in place, translate it to the origin, rotate, and translate back to original pos. Assuming the earth is rotating around the sun, and the moon around the earth ... to rotate the moon, move earth to the origin (dragging moon with it), rotate moon around earth, and move both back.

##### Share on other sites
Thanks for the help guys!

/*
I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)
*/

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 18
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632662
• Total Posts
3007702
• ### Who's Online (See full list)

There are no registered users currently online

×