Rotating means recalculating your points, based on the angle and rotation point. Do you want to rotate from the center of the canvas, or from the bottom-left ?
pritaeas
Posting Prodigy
9,313 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86
I'll try to make an example on how to rotate a single point around the center. Just need some time though, I don't have it laying around.
pritaeas
Posting Prodigy
9,313 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86
I'll give you just the math, perhaps it will get you started. This assumes the point of rotation to be (0, 0). Assume point P(10, 20).
If you want to rotate this point 45 degrees, then you have to do the following:
angle := 45 * pi / 180; // conversion of degrees to radials
Q(x, y) is calculated as follows:
x := 10 * cos(angle) - 20 * sin(angle); // 10 = Px, 20 = Py
y := 20 * cos(angle) + 10 * sin(angle);
pritaeas
Posting Prodigy
9,313 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86
Question Answered as of 1 Year Ago by
pritaeas,
Morten Brendefu
and
anijacity