Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get a point after rotating the rectangle

Tags:

java

math

I got a sprite, I know the position, and the rectangle behind. I want to get the location behind the sprite, I know the offset.

My point would be like:

Point p=new Point(sprite.getX()-offset,sprite.getY()-sprite.getHeight()/2);

If I rotate my sprite around its center origin, I want to get the new location of that point.

An image that will explain better:

enter image description here

like image 580
Boldijar Paul Avatar asked Oct 03 '22 00:10

Boldijar Paul


1 Answers

You need to provide the coordinates of the rotation center (the point which remains fixed).

X' = (X - Xc) * cos(A) - (Y - Yc) * sin(A) + Xc
Y' = (Y - Yc) * cos(A) + (X - Xc) * sin(A) + Yc

And it would also be nice to tell us what does not work, as you don't give a clue...

like image 164
Yves Daoust Avatar answered Oct 13 '22 12:10

Yves Daoust