简体   繁体   中英

How to find new coordinates from translation rotation

I have one coordinate and want to get a new coordinate after rotation like image below. Can anyone give me a simple formula ?

在此处输入图片说明

EDIT : after using eol formula...

除错

there's a very small miss "6.1232338E-15".

Just use a rotation matrix (taken from https://en.wikipedia.org/wiki/Rotation_matrix ):

float newX = x*Math.cos(angleRad) - y*Math.sin(angleRad);
float newY = x*Math.sin(angleRad) - y*Math.cos(angleRad);

One thing to mention is that you need to make sure that the angle is in radians, so you may need to perform this conversion:

float angleRad = angle*Math.PI/180;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM