15

如何生成玫瑰?|数字艺术

 3 years ago
source link: https://mp.weixin.qq.com/s?__biz=MzA3MDgyMjMwMA%3D%3D&%3Bmid=2649941051&%3Bidx=1&%3Bsn=552017782cd215e8d88f12b03c9a1d76
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.

iIbEZbv.jpg!mobile

现象背后的规律,总是令人着迷的!

今天我们来看莫拉尔玫瑰 (Maurer rose)的做法,也有将 Maurer rose 翻译成毛瑞尔,它是一种很漂亮的图形 —— 玫瑰线的变异品种。

相关软件:数学图形可视化工具

莫拉尔玫瑰

Maurer rose

A3Q3ayF.png!mobile

A Maurer rose with n = 7 and d = 29

函数 $r=sin(n\theta)$ 在极坐标中展现出的图像是一个类似玫瑰花的图案,其中 $n$ 是一个正整数。如果 $n$ 是奇数,那么就有 $n$ 个花瓣;如果 $n$ 是偶数,就有 $2n$ 个花瓣。

我们在玫瑰花上取361个点,$sin(nk)(k = 0, d, 2d,3d,..., 360d)$,其中d是正整数,角度是" 弧 "不是 "度"。

莫拉尔玫瑰曲线

$r = sin(n\theta)$曲线:莫拉尔玫瑰曲线,是由连续连接的360条线连接组成。因此,莫拉尔玫瑰曲线是具有顶点的多边形曲线。

莫拉尔玫瑰可以描述为极面的闭合路线。

从原点$(0, 0)$开始触发,然后沿着一条线画到点$(sin(n*d), d)$。然后,在第二个点,沿着一条线画到下一个点$(sin(n*2d), 2d)$,依此类推。

最终,在最后一点,沿着一条线从$(sin(n* 359d),359d)$画到终点$(sin(n* 360d),360d)$。整个线图就是莫拉尔玫瑰曲线$r = sin(n\theta)$。

Maurer玫瑰是闭合曲线,因为起点$(0,0)$和终点$(sin(n*360d),360d)$重合。

下图显示了莫拉尔玫瑰曲线的演化$(n = 2, d = 29)$。

更多案例展示

qU7B3av.png!mobile

以上是一些用$n$和$d$值绘制的 Maurer 玫瑰

实现路径

float n = 6;
float d = 71;

size(800, 800);

noFill();
background(255);

// 绘制蓝线
beginShape();
stroke(0, 0, 255);
strokeWeight(0.5);
for(int theta = 0; theta <= 360; theta++){
float k = theta * d * PI / 180;
float r = 300 * sin(n * k);
float x = r * cos(k) + width/2;
float y = r * sin(k) + height/2;
vertex(x, y);
}
endShape();

// 绘制红线
beginShape();
stroke(255, 0, 0);
strokeWeight(4);
for(int theta = 0; theta <= 360; theta++){
float k = theta * PI / 180;
float r = 300 * sin(n * k);
float x = r * cos(k) + width/2;
float y = r * sin(k) + height/2;
vertex(x, y);
}
endShape();

实验结果图

I7Vvqy3.png!mobile

Vvuuq2B.jpg!mobile

恒成立

上海理工大学光电硕士

努力将数字公式可视化

- END -

获取年会分享录播

请加入知识星球

置顶文件 (不定期放出)

戳星球二维码 ↓

iyUvqyB.jpg!mobile


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK