Introduction
Following the double angle line , then try the heart-shaped line (Cardioid).
Introduction
Cardioid is the Castillon first used in a paper in "Philosophical Transactions of the Royal Societyin" in 1741. It is a curve, a track formed by a point on the circumference rotating around the circumference of a circle of equal radius.
The formula is described in the Cartesian coordinate system:
Where a is a constant.
draw
Parametric conversion:
This is the example , drawing the main logic code:
function draw() {
let a = 40, start = 0;
let x = 0, y = 0, points = [];
const acceleration = 0.1, max = 40;
while (start <= max) {
const cal = 2 * start;
x = a * (2 * Math.cos(start) - Math.cos(cal));
y = a * (2 * Math.sin(start) - Math.sin(cal));
points.push([x, y]);
start = start + acceleration;
}
// 实现把点绘制成线的方法
line({ points: points});
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。