4

JavaScript 数学曲线—星形线

 2 years ago
source link: https://segmentfault.com/a/1190000040924050
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

JavaScript 数学曲线—星形线

连锁螺线,接着尝试星形线(Astroid)。

Johann Bernoulli 在 1691-1692 年首次讨论了星形线。它也出现在 Leibniz 1715 年的信件中。它有时被称为四尖瓣,很明显因为它有四个尖。

Astroid 直到 1836 年才在维也纳出版的一本书中获得了现在的名称。即使在 1836 年以后,文献中也出现了各种名称,包括 cubocycloid 和 paracycle 。

在笛卡尔坐标系中公式描述:

其中 a 为常数。

参数化转换:

这是示例,绘制主要逻辑代码:

function draw() {
  let a = 100, start = 0;
  let x = 0, y = 0, points = [];
  const acceleration = 0.1, max = 20;
  while (start <= max) {
    x = a * Math.pow(Math.cos(start), 3);
    y = a * Math.pow(Math.sin(start), 3);
    points.push([x, y]);
    start = start + acceleration;
  }
  // 实现把点绘制成线的方法
  line({ points: points});
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK