简体   繁体   English

谁能解释这个Java代码段?

[英]Can anyone explain this snippet of Javascript?

Can anyone explain the following code? 谁能解释以下代码? Forget the sine and cosine parts. 忘记正弦和余弦部分。 Is it trying to build a space for the object? 是否正在尝试为对象建立空间?

objectsInScene = new Array();

for (var i=space; i<180; i+=space) {

  for (var angle=0; angle<360; angle+=space) {

    var object = {};

    var x = Math.sin(radian*i)*radius;
    object.x = Math.cos(angle*radian)*x;
    object.y = Math.cos(radian*i)*radius;
    object.z = Math.sin(angle*radian)*x;
    objectsInScene.push(object);
  }
}

If I'm not much mistaken it's arranging objects in a hemi spherical shape. 如果我没有弄错它在一个 球形形状配置对象。

objectsInScene is an array of all these objects. objectsInScene是所有这些对象的数组。

It's filling objectsInScene with a sphere of points (not a hemisphere), spaced space degrees apart. 它填充objectsInScene与点的球体 (不是半球),间隔space隔开度。 The diameter is 2 times radius . 直径是radius 2倍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM