有人可以解释一下公式吗 [英] Can someone explain the formula

查看:89
本文介绍了有人可以解释一下公式吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一个公式可以执行以下操作:

https://threejs.org/examples/css3d_periodictable.html (球形版本)

我稍微修改了代码以使用对象,但在其背后的数学运算中未做任何更改.

我的问题是,是否有人可以解释该头寸计算中到底发生了什么.

这是代码:

for ( var i = 0, l = 30; i < l; i ++ ) {

    var phi = Math.acos( -1 + ( 2 * i ) / l );
    var theta = Math.sqrt( l * Math.PI ) * phi;

    var object = new THREE.Mesh( geometry, material );

    object.position.x = 1000 * Math.cos( theta ) * Math.sin( phi );
    object.position.y = 1000 * Math.sin( theta ) * Math.sin( phi );
    object.position.z = 1000 * Math.cos( phi );

    scene.add(object);

}

我希望有人能够帮助我

预先感谢

解决方案

此代码将笛卡尔坐标转换为球坐标.在坐标系转换上检查此Wikipedia条目.

绘制球形的最佳方法;)

I have found a formula which does the following:

https://threejs.org/examples/css3d_periodictable.html (the sphere version)

I modified the code a little bit to work with my objects, but changed nothing in the math behind it.

My question is if someone can explain what is exactly happening in the calculation for the position.

This is the code:

for ( var i = 0, l = 30; i < l; i ++ ) {

    var phi = Math.acos( -1 + ( 2 * i ) / l );
    var theta = Math.sqrt( l * Math.PI ) * phi;

    var object = new THREE.Mesh( geometry, material );

    object.position.x = 1000 * Math.cos( theta ) * Math.sin( phi );
    object.position.y = 1000 * Math.sin( theta ) * Math.sin( phi );
    object.position.z = 1000 * Math.cos( phi );

    scene.add(object);

}

I hope someone is able to help me

Thanks in advance

解决方案

This code is transforming Cartesian coordinates to spherical coordinates. Check this wikipedia entry on coordinate system convertions.

The best way to draw a sphere ;)

这篇关于有人可以解释一下公式吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆