JavaScript 数学曲线—星形线

142 阅读1分钟

引子

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

简介

88-1

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

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

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

88-2

其中 a 为常数。

绘制

参数化转换:

88-3

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


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});

}

参考资料

最近看了电影《燃烧》,看到大概一半的时候才明白了电影名称的含义。

88-poster