Advertisement
Advertisement
| 04.11.2008 at 05:48PM PDT, ID: 23316788 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: |
public Point[] rotatePolygon(Point[] polygon, Point centroid, double angle)
{
for(int i = 0; i < polygon.Length; i++)
{
polygon[i] = rotatePoint(polygon[i], centroid, angle);
}
return polygon;
}
public Point rotatePoint(Point point, Point centroid, double angle)
{
int x = centroid.X + (int)((point.X - centroid.X) * Math.Cos(angle) - (point.Y - centroid.Y) * Math.Sin(angle));
int y = centroid.Y + (int)((point.X - centroid.X) * Math.Sin(angle) + (point.Y - centroid.Y) * Math.Cos(angle));
return new Point(x, y);
}
|