#### Archived

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

# Rotation around a point.

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

## Recommended Posts

I have been having trouble with making an object rotate around a given point, like an orbit. I have seen plenty of tutorials that show you how to make an object (such as a cube) rotate on the spot, but I don''t want a cube that rotates. I want one that orbits a given point. Can anyone help me?

##### Share on other sites
i would use the same idea as rotating on a point, but instead of centering it on that point, position it as far away as the radius of the orbit.

i.e. instead of making a square (less points )
1, 1
1, -1
-1, 1
-1, -1

make it

16, 16
16, 14
14, 16
14, 14

and that way it will rotate in an obit 14 from the center.

-------------------------------------------------
Don''t take life too seriously, you''''ll never get out of it alive. -Bugs Bunny

##### Share on other sites
obj.rotate(deg);
obj.trans(direction);

gl commands
glRotatef( deg, axis.x, axis.y, axis.z );
glTranslatef( direction.x, direction.y, direction.z );

enjoy

##### Share on other sites
Andy Pike tutorial 9. very cool, you can remove the cones and cylinders though.

If love is illusion and hate is real, I would rather be crazy

##### Share on other sites
I see where your coming from, but there''s one problem. The thing I want to have in orbit is actually a light. I should have mentioned that before.

##### Share on other sites
OB1st, where do I find Andy Pike''s Tutorial 9?

##### Share on other sites
You can find the excellent tutorials of andy pike at:

http://www.andypike.com/tutorials/directx8/

##### Share on other sites
Try having a variable that has the current angle, and then one that has the distance from the object. Every frame, increment the current angle. The formula would be something like:

x = sin(curAngle) * distance
y = cos(curAngle) * distance

Something like that...

Hope that helps

Simon

##### Share on other sites
Hey there,

For any object you should generally keep it''s own coordinates relative. Meaning, always have it centered around the origin. Then, you can rotate the object around it''s own local coords. From there you can move the object (translate) it from the orgin to another point (similar to bones). After that translation is preformed, you can rotate the object again. This will cause the object to rotate around the origin from that offset. So on and so forth.

Matrices:
R1 (rotation around orbit point)
T0 (the offset distance to orbit)
R0 (rotation around itself)

R1 * T0 * R0 == orbit

...that should be what you''re looking for.

-tim

##### Share on other sites
I made this to rotate one way:
EX and EZ are the Eye position, BX and BZ is the Look at position.

D = D - 10
If D > 360 Then D = 1
BX = EX + (Sin((D * pi) / 180))
BZ = EZ + (Sin(((D + 90) * pi) / 180))

And to turn the other way...

D = D + 10
If D < 1 Then D = 360
BX = EX + (Sin((D * pi) / 180))
BZ = EZ + (Sin(((D + 90) * pi) / 180))

I hope it helps?
Matt

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011319
• ### Who's Online (See full list)

There are no registered users currently online

×