Computer Science Canada Trig origin |
Author: | Degensquared [ Fri Oct 26, 2007 10:43 am ] | ||
Post subject: | Trig origin | ||
I have just created a program that allows the user to rotate a box, w, (drawn with 4 lines) using trig, but it only rotates from the top left hand corner, I know how to make it rotate from another corner, but I'm not sure how to change the origin that it rotates around to the center, not one of the points for the lines.
|
Author: | richcash [ Fri Oct 26, 2007 11:56 pm ] | ||||||
Post subject: | Re: Trig origin | ||||||
Are you having trouble with finding out the coordinates of the center of a rectangle or are you having trouble with rotating a box around a point (which is basically the same as rotating 4 points around a point of rotation)? Do the following for all four points and join the new points to get the new box. 1) Find the angle of the line joining each point and the point of rotation by using arctan
2) Find the distance between each point and the point of rotation by using pythagorean theorem :
3)To rotate a point by n degrees, use :
*The above is pseudocode. |