简体   繁体   English

如何从平移旋转中查找新坐标

[英]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... 编辑:使用eol公式后...

除错

there's a very small miss "6.1232338E-15". 有一个非常小的小姐“ 6.1232338E-15”。

Just use a rotation matrix (taken from https://en.wikipedia.org/wiki/Rotation_matrix ): 只需使用旋转矩阵(取自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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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