I am rotating a sprite in game around the center, and need to find out where a certain point is, from the original, so for example in the original a point at (1, 1) on the 64 x 128 image. I need to find that point after the rotation. I am using slick2d as my graphics library
This is what I use to rotate points, only I use Vector2D, but it works the same way.
public static Vector2D rotate(Vector2D origin,Vector2D point, double theta){
double s = Math.sin(theta);
double c = Math.cos(theta);
// get the deltaX and deltaY
point.x -= origin.x;
point.y -= origin.y;
// rotate point
double xnew = point.x * c - point.y * s;
double ynew = point.x * s + point.y * c;
// translate point back to global coords:
Vector2D TranslatedPoint = new Vector2D(0,0);
TranslatedPoint.x = xnew + origin.x;
TranslatedPoint.y = ynew + origin.y;
return TranslatedPoint;
}
Oh cool thanks, i found a way like this of wikipedia’s rotation page, but thanks for the help anyways