小编Pop*_*lop的帖子

笛卡尔坐标和球坐标之间的转换

我需要在 JavaScript 中的笛卡尔坐标和球坐标之间进行转换。我在论坛上简单地看了看,并没有找到我想要的东西。

现在我有这个:

this.rho = sqrt((x*x) + (y*y) + (z*z));
this.phi = tan(-1 * (y/x));
this.theta = tan(-1 * ((sqrt((x * x) + (y * y)) / z)));
this.x = this.rho * sin(this.phi) * cos(this.theta);
this.y = this.rho * sin(this.phi) * sin(this.theta);
this.z = this.rho * cos(this.phi);
Run Code Online (Sandbox Code Playgroud)

我使用球坐标系笛卡尔到球坐标计算器计算我的公式。

但是我不确定我是否正确地将它们翻译成代码。

javascript math

3
推荐指数
1
解决办法
2548
查看次数

标签 统计

javascript ×1

math ×1