0
我已經做了一些關於從一定的角度和某個角度旋轉一個點的調查問題:C++: Rotating a vector around a certain point我已經提出了以下至今,但它並沒有給我正確的結果,請有人請找出問題在某一點附近的點的角度
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);
我得到:下一頁末= 240和newY = 400
編輯: 我有一個奇怪的飛機雖然
|
| ^
| |
|
------->^(320, 480) | (y+)
90° | | |
| | |
| |
. (320, 320) |
|
|
--------------------------(0,0)
<-- (x+) --
如果我想找出點(320,480)的90度角,如果線向左和向右下降
事實上,更確切地說,平面是倒置的(基本上我使用的是QGraphicsScene所以左上角是0,0和右下角是寬度(),高度()
(x+) --->
(0,0) --------------------------
|
|
| . (320, 320)
| |
| |
| | 90°
| . (320, 480)----------
|
|
(y+) |
|
|
您是否使用弧度值?據我記憶,大多數正弦/餘弦函數期望它們的弧度。 – Losiowaty 2013-02-27 08:49:11
@Losiowaty好吧,如果我將它從弧度改爲度數(-160,2.87183e-07) – abumusamq 2013-02-27 09:00:37
不,弧度是好的:)這只是首先想到的問題。 – Losiowaty 2013-02-27 09:06:04