This is what I use to rotate points, only I use Vector2D, but it works the same way.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public static Vector2D rotate(Vector2D origin,Vector2D point, double theta){ double s = Math.sin(theta); double c = Math.cos(theta); point.x -= origin.x; point.y -= origin.y;
double xnew = point.x * c - point.y * s; double ynew = point.x * s + point.y * c;
Vector2D TranslatedPoint = new Vector2D(0,0); TranslatedPoint.x = xnew + origin.x; TranslatedPoint.y = ynew + origin.y;
return TranslatedPoint; } |