[英]Angle of point around certain point
我对从某个点到某个角度以及从某个角度以某个角度旋转一个点进行了一些调查: C ++:到目前为止,我一直想出一个围绕某个点旋转矢量的方法,但是它没有给我正确的结果,有人可以识别一下吗问题
const float angle = -90.0;
const float degreePerRadian = 57.2957795;
const float s = sin(angle / degreePerRadian);
const float c = cos(angle / degreePerRadian);
int p1x = 320;
int p1y = 480;
int p2x = 320;
int p2y = 320;
float centerX = (p2x - p1x) / 2 + p1x;
float centerY = (p2y - p1y) / 2 + p1y;
p2x -= centerX;
p2y -= centerY;
double newX = centerX + (p2x * c - p2y * s);
double newY = centerY + (p2x * s + p2y * c);
我得到:newX = 240和newY = 400
编辑:虽然我有一个奇怪的飞机
|
| ^
| |
|
-------> ^ (320, 480) | (y+)
90° | | |
| | |
| |
. (320, 320) |
|
|
--------------------------(0,0)
<-- (x+) --
如果和我想找出直线(左右)分别落在点(320、480)的90度角
实际上更确切地说,平原是上下颠倒的(基本上我正在使用QGraphicsScene,所以左上角是0,0,右下角是width(),height()
(x+) --->
(0,0) --------------------------
|
|
| . (320, 320)
| |
| |
| | 90°
| . (320, 480)----------
|
|
(y+) |
|
|
您来自链接的第16行代码不正确。 它应该是:
double newY = centerY +(p2x * s + p2y * c);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.