Math Help: Box Rotation

BlitzMax Forums/BlitzMax Programming/Math Help: Box Rotation

ima747(Posted 2012) [#1]
I have a central point, and an orientation, I need to find the position of 4 points that make up a square around the box but my googling abilities are failing me...

Given the position 10,10, an orientation of 0deg, and a box size of 4 units the points would be (clockwise starting from upper left).
x | y
--------
8 | 12
12| 12
12| 8
8 | 8

total brain fart, I think it has to do with the pythagorean theorem, but I can't recall how to work the angle into it. any help would be much appreciated.


jkrankie(Posted 2012) [#2]
corner1X=radius*cos(angleOfBox)+x
corner1Y=radius*sin(angleOfBox)+y

corner2X=radius*cos(angleOfBox+90)+x
corner2Y=radius*sin(angleOfBox+90)+y

and so on. You'll likely need to add an offset to the angleOfBox in order to get it to appear flat at 0 degrees though.

Cheers
Charlie


Jesse(Posted 2012) [#3]
double post

Last edited 2012


Jesse(Posted 2012) [#4]
you can look at my my box rotated collision code in the code arch see if it helps:
http://www.blitzmax.com/codearcs/codearcs.php?code=2806

Last edited 2012


ima747(Posted 2012) [#5]
Aaah, excelent thank you muchly!