1

球座標 (シータ、ファイ、アルファ) を取得するには、次のコードを使用します。

double phi_rad = atan2f(z,sqrt((x*x)+(y*y)));
double theta_rad = atan2f(y, x);
double r = sqrt((x*x)+(y*y)+(z*z));

シータを 0 ~ 360 度にマップするには、次のコードを使用します。

double theta_deg = (theta_rad/M_PI*180) + (theta_rad > 0 ? 0 : 360);

しかし、どうすればファイを0〜360度にマッピングできますか? theta_deg に使用したのと同じ原理を試しましたが、うまくいきません。

4

1 に答える 1

0

phi が方位角 (0 から 2π) であり、theta が極角 (0 から π) である場合、次のことができます。

double phi_rad = atan2(y,x);
double theta_rad = acos(z);

次に、標準を使用してラジアンから度に変換できます。

double rad2deg(double rad)
{
    return rad * 180.0 / M_PI;
}
于 2013-12-13T11:01:49.123 に答える