How can I use matrix algebra to rotate a polygon and calculate new coordinates?

In summary, the conversation discusses rotating a polygon on a graph and calculating the new coordinates of each vertex. Matrix algebra is involved, and a rotation of ##\theta## radians clockwise is given by a 2x2 matrix. The center of rotation can be determined using the original coordinates, and the new coordinates can be found by multiplying the rotation matrix by the original coordinates. The conversation also delves into determining the outermost points of a complex polygon and the concept of isometric transformation in Euclidean geometry.
  • #1
thetexan
268
11
Let's say I have a 5 vertex polygon drawn on a x/y graph. Each of those vertices have an x/y coordinate.

Now let's say I want to rotate the polygon 25 degrees clockwise and calculate the new coordinates of each vertex.

How can I do that so that by knowing the original coordinate I can do a math transformation and know the resulting coordinate?

Is matrix algebra involved? Is there a simple way that a math challenged guy like me can understand?

Tex
 
Mathematics news on Phys.org
  • #2
Shift everything so that the center is your origin.
Counterclockwise rotation of a point (x;y) is the same as multiplication by a 2x2 matrix.
 
  • #3
Assume the center is the origin.

A rotation of ##\theta## radians clockwise is given by the matrix

[tex]\left(\begin{array}{cc} \cos(\theta) & -\sin(\theta)\\ \sin(\theta) & \cos(\theta)\end{array}\right)[/tex]

Thus if you have the original coordinates ##(x,y)##, then after the rotation, you have the coordinates (written in a column)

[tex]\left(\begin{array}{cc} \cos(\theta) & -\sin(\theta)\\ \sin(\theta) & \cos(\theta)\end{array}\right)\left(\begin{array}{c} x\\ y\end{array}\right)[/tex]
 
  • Like
Likes aikismos
  • #4
I have no experience or education in matrix math but I"m willing to learn.

Do you mean to put the center of the polygon at the x/y origin? How do I determine where that is if it is a complex poly?
And do I multiply the 2x2 matrix by the 1x2 xy matrix?

tex
 
  • #5
thetexan said:
I have no experience or education in matrix math but I"m willing to learn.

Do you mean to put the center of the polygon at the x/y origin? How do I determine where that is if it is a complex poly?

Are you not working with a regular polygon? If not: which point is the center of rotation.

And do I multiply the 2x2 matrix by the 1x2 xy matrix?

If the center of rotation is ##(0,0)## and ##(x,y)## are the old coordinates, then the new coordinates are
[tex](x\cos(\theta) - y\sin(\theta), x\sin(\theta) + y\cos(\theta))[/tex]
 
  • #6
What do you mean by a "complex poly"?
 
  • #7
I mean a polygon that has many sides and is irregular in shape. I am working on an algorithm that will determine which points of the polygon are the outermost. By that I mean if I were to redraw a fence aroung the outer most points it would encompass all point including the ones inside of that. Anyway...my way of doing determining which points those are is to rotate the polygon twice and remeasure the extreme points.

So I just need to know a good method (that I can understand) to do the rotation. I want to take the polygon and measure it in its original position, then rotate it 120 degrees and measure it again, and do that one more time.

So it seems that all I have to do is to put the point of rotation within the polygon, note the coordinates of each vertex in that orientation then rotate about that center point 120 degrees. I can do that. I am just wondering if there is a mathematical way (such as matrix math, on which I will need some help) that will mathematically rotate the polygon and produce the new coordinates.

tex
 
  • #8
thetexan said:
I mean a polygon that has many sides and is irregular in shape. I am working on an algorithm that will determine which points of the polygon are the outermost. By that I mean if I were to redraw a fence aroung the outer most points it would encompass all point including the ones inside of that. Anyway...my way of doing determining which points those are is to rotate the polygon twice and remeasure the extreme points.

So I just need to know a good method (that I can understand) to do the rotation. I want to take the polygon and measure it in its original position, then rotate it 120 degrees and measure it again, and do that one more time.

So it seems that all I have to do is to put the point of rotation within the polygon, note the coordinates of each vertex in that orientation then rotate about that center point 120 degrees. I can do that. I am just wondering if there is a mathematical way (such as matrix math, on which I will need some help) that will mathematically rotate the polygon and produce the new coordinates.

tex

For Euclidean geometry, rotation is an isometric transformation. The distances between points is preserved. I do not understand what "measurement" of the polygon means. Based on isometry, I expect that you would get the same result for each rotation.
 

Related to How can I use matrix algebra to rotate a polygon and calculate new coordinates?

1. How do I rotate a polygon in a 2D space?

To rotate a polygon in a 2D space, you can use a rotation matrix. This involves multiplying the coordinates of the polygon by a matrix that represents the desired rotation angle. The resulting coordinates will be the new rotated polygon.

2. How do I determine the center of rotation for a polygon?

The center of rotation for a polygon can be determined by finding the average of all the x-coordinates and y-coordinates of the polygon's vertices. This will give you the coordinates for the center point, which will be used in the rotation matrix.

3. Can a polygon be rotated around a specific point?

Yes, a polygon can be rotated around a specific point by first translating the polygon so that the desired point is at the origin, then applying the rotation matrix, and finally translating the polygon back to its original position.

4. How do I rotate a polygon in a 3D space?

To rotate a polygon in a 3D space, you can use a combination of rotation matrices for each axis (x, y, and z). This involves multiplying the coordinates of the polygon by each matrix in the desired order to achieve the desired rotation.

5. Is there a difference between rotating a polygon clockwise or counterclockwise?

Yes, there is a difference between rotating a polygon clockwise or counterclockwise. This is because the direction of rotation determines the sign of the angle in the rotation matrix. Clockwise rotation will have a negative angle, while counterclockwise rotation will have a positive angle.

Similar threads

Replies
2
Views
1K
Replies
1
Views
748
Replies
3
Views
757
Replies
8
Views
5K
Replies
1
Views
1K
Replies
2
Views
670
Replies
2
Views
1K
Back
Top