极地和笛卡尔计算不完全有效?

Smo*_*oka 1 .net trigonometry cartesian

double testx, testy, testdeg, testrad, endx, endy;

testx = 1;
testy = 1;
testdeg = atan2( testx, testy) / Math::PI* 180;  
testrad = sqrt(pow(testx,2) + pow(testy,2));
endx = testrad * cos(testdeg);
endy = testrad * sin(testdeg);
Run Code Online (Sandbox Code Playgroud)

这个部分似乎等同于正确,除了endx和endy应该= testx和testy他们在手工计算时做.

int*_*jay 8

我在这里可以看到两个可能的问题:

  • atan2在我所知道的每种语言中按顺序(y,x)获取参数.你传入了(x,y).
  • cossin以弧度为参数,但你以度为单位给它们.将乘法移除180/pi以保持角度为弧度.