#### Archived

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

# need some help with rotating objects in circles

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

## Recommended Posts

right now in my program i have a tank bottom that i wish to rotate... i used a formula to find out all the y coordinates that matched the x coordinates around the circle and redrew my tank bottom(a sqaure) based on that... it would fine rotating but as i move around the circle my sqaure gets skinner and stuff here is a pic of it in its starting position... here is a pic of it at is skinnest piont... (it will get bigger than smaller and stuff) those red line are there just to make sure its rotating proporly and stuff... can any of you guys explain to me why it gets skinny, mabe how to solve it or how you would go about spining an sqaure inside a circle. thanx [edited by - deadlypencil on May 5, 2002 1:05:17 PM]

##### Share on other sites
http://www.gamedev.net/reference/articles/article811.asp

,Jay

##### Share on other sites
if you want to rotate 2D polygons use those formulas:

new_x =

new_y =

note that ox and oy are respectivly the X axis and the Y axis cooridinates of the point you want to rotate your object around.

tell me if you want a mathematical proof for those .

[edited by - xeno on May 5, 2002 1:31:07 PM]

##### Share on other sites
umm ok ill try and get that to work... what do i have to include to use sin/cos???

soooo... if i want to rotate it aroudn like point 50,50... my ox and oy would be teh 50,50 then?[/edit]

[edited by - stickman on May 5, 2002 1:59:17 PM]

##### Share on other sites
quote:
Original post by stickman
umm ok ill try and get that to work... what do i have to include to use sin/cos???

Math.h

quote:

soooo... if i want to rotate it aroudn like point 50,50... my ox and oy would be teh 50,50 then?[/edit]

[edited by - stickman on May 5, 2002 1:59:17 PM]

Yep .

##### Share on other sites
it doesn''t seem to be working....
the point is originally at about 135 degrees

and the xy is 50,50

when i change the angle to 150 degrees the x coord becomes 85 with your formula... the x should be going down not up...

can anyone help?

<div CLASS=source>
 	if (KEYDOWN(VK_LEFT))	{		angle=angle+10;		old_x = p1.tl_sq_x;		old_y = p1.tl_sq_y;		p1.tl_sq_x =(old_x - p1.clo_gun_x)*(cos(angle*DEGTORAD)) - (old_y - p1.clo_gun_y)*(sin(angle*DEGTORAD)) + p1.clo_gun_x;		p1.tl_sq_y =(old_y - p1.clo_gun_y)*(cos(angle*DEGTORAD)) + (old_x - p1.clo_gun_x)*(sin(angle*DEGTORAD)) + p1.clo_gun_y;	  }
</div>

##### Share on other sites

NM i solved the problem

[/edit]

[edited by - stickman on May 5, 2002 5:28:31 PM]