【发布时间】:2014-09-16 13:30:18
【问题描述】:
我正在 Three.js 中创建一个椭圆的点云,并且有两个问题看起来很简单,但我已经坚持了几天:
- 云应该是椭圆形的,在
x轴上具有最长轴 - 目前它以x轴上的最短轴定向 - 虽然我用于云的fiddle 看起来完全是椭圆形的,但我文件中的工作代码在
x轴上的y = 0处有几个点,它们似乎随着他们自己鼓手的节拍而运行——它们是像士兵一样排列在椭圆两侧的y = 0上,尺寸为length(见下面的截图)。两个文件都包含相同的椭圆数学运算 - 这是怎么回事?
谢谢!
椭圆点云的代码:
particleCount = 300;
for (var p = 0; p < particleCount; p++) {
// ELLIPTICAL
var length = 200; // x (major axis)
var width = 75; // y (minor axis)
var pX = (Math.random() * length);
// solve for length of vertical chord at pX:
var chord;
var rightBisector = Math.abs((length/2) - pX);
chord = (2 * length) * Math.sqrt(1 - Math.exp(2 * Math.log(rightBisector/width)));
var pY = (Math.random() * chord);
pX -= length/2; // center the cloud horizontally
pY -= chord/2; // center the cloud vertically
// END ELLIPTICAL
// Make image particle at pX, pY and add to system
【问题讨论】:
标签: javascript graphics three.js geometry particle-system