# Rotation question

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

## Recommended Posts

Hi All Suppose you have a 2D rectangle that has 4 points ,P1 P2 P3 and P4. how to calculate the final rectangle coordinates after rotating it by theta angle. The known data are 1- Center coordinate Cx , Cy of rectangle. 2- The half Width and half Height hWidth, halfWidth of the rectangle. 3- The Theta angle. I have tried the next calculation but it does not work correctly , so any help please ? cos_value = cos(Theta) sin_value = sin (Theta) x1 = Cx - hWidth x2 = Cx + hWidth x3 = Cx + hWidth x4 = Cx - hWidth y1 = Cy + hHeight y2 = Cy + hHeight y3 = Cy - hHeight y4 = Cy – hHeight point1.x = x1 * cos_value - y1 * sin_value point1.y = x1 * cos_value + y1 * sin_value point2.x = x2 * cos_value - y2 * sin_value point2.y = x2 * cos_value + y2 * sin_value point3.x = x3 * cos_value - y3 * sin_value point3.y = x3 * cos_value + y3 * sin_value point4.x = x4 * cos_value - y4 * sin_value point4.y = x4 * cos_value + y4 * sin_value

##### Share on other sites
Hi,

you are close :-)

the equation you need to is:

x' = x * cos(theta) - y * sin(theta)
y' = x * sin(theta) + y * cos(theta)

(x', y') are the rotated coordinates

So just exchange cos with sin in pointX.y

##### Share on other sites

thanks rozz666 :-)

it works ok.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 100
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009659
• ### Who's Online (See full list)

There are no registered users currently online

×