Advertisement

rotating a box on a center (re-worded)

Started by December 29, 2000 08:18 AM
1 comment, last by redmonkey 24 years ago
right, the ways i explain stuff really sucks (see last post ) so here''s a much better way of explaining it: i have a box, the box has a specified center, (say xc yc) and then four corners(x1,x2,x3,x4,y1,y2,y3,y4), each with its own offset from the center i need to rotate my box (on the center xc,xy) by an angle (a) this is where i run into problems. (i cant find an example or explanation of how to do it) hopefully this is a lot simplier to understand, and mebe someoen can help me out, (provide some code, explain how to do it etc) icq me if possible: 13548542 __________________ graham "red" reeves. red@deadpenguin.org www.deadpenguin.org
__________________graham "red" reeves.[email=red@deadpenguin.org]red@deadpenguin.org[/email]www.deadpenguin.org
I''m guessing this is all in 2d space, am I right?

Here''s what you need, if it is 2d space.

1) Translate everything by (-xc, -yc). This makes the boxes center the origin.

2) Rotate everything around the origin.

3) Translate everything by (xc, yc).

This becomes very simple when you use vector/matrix math.
You can feel free to email me, if you need more help.

jesse@k-isilabs.com
Jesse Chounard
Advertisement
I assume its 2D and you want to rotate the square clockwise (?)

(I assume that these points are points not offsets ie : 153,234) take your points :

(x1,y1) top left
(x2,y2) top right
(x3,y3) bottom right
(x4,y4) bottom left

      //do this with all the points 1 though 4newx1 = (x1-cx)*Cos(Deg) +        (y1-cy)*Sin(Deg);newy1 = (y1-cy)*Cos(Deg) -        (x1-cx)*Sin(Deg);x1 = newx1 + cx;y1 = newy1 + cy;      


Hope it helps.
If you want 3D E-mail me at Xsist10@hotmail.com

X-sist

Help the meek for they inherit the world

Edited by - Xsist on December 29, 2000 10:01:34 AM
I burn cold

This topic is closed to new replies.

Advertisement