使用GGPLOT绘制Hamid Naderi Yeganehs鹦鹉

发布于 2025-01-22 23:18:53 字数 2509 浏览 5 评论 0原文

我是A)新手stackoverflow和b)r ;--)的高级初学者,

我看到了一些Yeganeh的鸟艺术品-birds_b_8876904“ rel =“ nofollow noreferrer”>用数学绘制飞行中的鸟类,并希望在R中重现它们以对颜色等进行一些实验。

但是,尽管这一结果取得了不错的成绩:

k <- 1:9830

X <- function(k) {
  sin(pi * k / 20000) ^ 12 *
    (0.5 * cos(31 * pi * k / 10000) ^ 16 *
       sin(6 * pi * k / 10000) + (1 / 6 * sin(31 * pi * k / 10000)) ^ 20) +
    3 * k / 20000 + cos(31 * pi * k / 10000) ^ 6 *
    sin((pi / 2) * ((k - 10000) / 10000) ^ 7 - pi / 5)
}

Y <- function(k) {
  -9 / 4 * cos(31 * pi * k / 10000) ^ 6 *
    cos(pi / 2 * ((k - 10000) / 10000) ^ 7 - pi / 5) *
    (2 / 3 + (sin(pi * k / 20000) * sin(3 * pi * k / 20000)) ^ 6) +
    3 / 4 * cos(3 * pi * ((k - 10000) / 100000)) ^ 10 *
    cos(9 * pi * ((k - 10000) / 100000)) ^ 10 *
    cos(36 * pi * ((k - 10000) / 100000)) ^ 14 +
    7 / 10 * ((k - 10000) / 10000) ^ 2
}

R <- function(k) {
  sin(pi * k / 20000) ^ 10 *
    (1 / 4 * cos(31 * pi * k / 10000 + 25 * pi / 32) ^ 20 +
       1 / 20 * cos(31 * pi * k / 10000) ^ 2) +
    1 / 30 * (3 / 2 - cos(62 * pi * k / 10000) ^ 2)
}

bird <- data.frame(x = X(k), y = Y(k), r = R(k))

library(tidyverse)
library(ggforce)

q <- ggplot() +
  geom_circle(aes(x0 = x, y0 = y, r = r), 
              data = bird, 
              n = 30) + 
  coord_fixed() +
  theme_void()

“用ggplot绘制的鸟”

以下代码产生了一些差不多的结果,这基本上应该是与功能差异有关。 (xa(k))+(yb(k))=(r(k))对于下面的鹦鹉,上面的鸟“简单”由k-th Circle(x(k),y(k))组成k-th Circle r(k)

k <- -10000:10000

A <- function(k) {
  (3*k/20000)+(cos(37*pi*k/10000))*sin((k/10000)*(3*pi/5))+(9/7)*(cos(37*pi*k/10000))*(cos(pi*k/20000))*sin(pi*k/10000)
}

B <- function(k) {
  (-5/4)*(cos(37*pi*k/10000))*cos((k/10000)*(3*pi/5))*(1+3*(cos(pi*k/20000)*cos(3*pi*k/20000)))+(2/3)*(cos(3*pi*k/200000)*cos(9*pi*k/200000)*cos(9*pi*k/100000))
}

R <- function(k) {
  (1/32)+(1/15)*(sin(37*pi*k/10000))*((sin(pi*k/10000))+(3/2)*(cos(pi*k/20000)))
}

parrot <- data.frame(a = A(k), b = B(k), r = R(k))

q <- ggplot() +
  geom_circle(aes(x0 = a, y0 = b, r = r), 
              data = parrot,
             n=30) + 
  coord_fixed() +
  theme_void()
q

“用ggplot绘制的parrot”

任何帮助将非常感谢。笛卡尔坐标已经应用如[在此处解释]()。从视觉的角度来看,似乎正确绘制了该功能,但是上面的“视图”需要更改...

谢谢!

I am a) new to stackoverflow and b) an advanced beginner to R ;-)

i saw some bird artworks of Yeganeh with the associated functions in the web Drawing Birds in Flight With Mathematics and wanted to reproduce them in R to experiment a bit with colouring and so on.

However, while this one yielded a quite good result:

k <- 1:9830

X <- function(k) {
  sin(pi * k / 20000) ^ 12 *
    (0.5 * cos(31 * pi * k / 10000) ^ 16 *
       sin(6 * pi * k / 10000) + (1 / 6 * sin(31 * pi * k / 10000)) ^ 20) +
    3 * k / 20000 + cos(31 * pi * k / 10000) ^ 6 *
    sin((pi / 2) * ((k - 10000) / 10000) ^ 7 - pi / 5)
}

Y <- function(k) {
  -9 / 4 * cos(31 * pi * k / 10000) ^ 6 *
    cos(pi / 2 * ((k - 10000) / 10000) ^ 7 - pi / 5) *
    (2 / 3 + (sin(pi * k / 20000) * sin(3 * pi * k / 20000)) ^ 6) +
    3 / 4 * cos(3 * pi * ((k - 10000) / 100000)) ^ 10 *
    cos(9 * pi * ((k - 10000) / 100000)) ^ 10 *
    cos(36 * pi * ((k - 10000) / 100000)) ^ 14 +
    7 / 10 * ((k - 10000) / 10000) ^ 2
}

R <- function(k) {
  sin(pi * k / 20000) ^ 10 *
    (1 / 4 * cos(31 * pi * k / 10000 + 25 * pi / 32) ^ 20 +
       1 / 20 * cos(31 * pi * k / 10000) ^ 2) +
    1 / 30 * (3 / 2 - cos(62 * pi * k / 10000) ^ 2)
}

bird <- data.frame(x = X(k), y = Y(k), r = R(k))

library(tidyverse)
library(ggforce)

q <- ggplot() +
  geom_circle(aes(x0 = x, y0 = y, r = r), 
              data = bird, 
              n = 30) + 
  coord_fixed() +
  theme_void()

bird plotted with ggplot

the following code yielded some weird result which should basically be related to the difference in the function. (x-A(k))+(y-B(k))=(R(k)) for the parrot below, whlie the bird above "simply" consisted of the k-th circle (X(k), Y(k)) and the radius of the k-th circle R(k)

k <- -10000:10000

A <- function(k) {
  (3*k/20000)+(cos(37*pi*k/10000))*sin((k/10000)*(3*pi/5))+(9/7)*(cos(37*pi*k/10000))*(cos(pi*k/20000))*sin(pi*k/10000)
}

B <- function(k) {
  (-5/4)*(cos(37*pi*k/10000))*cos((k/10000)*(3*pi/5))*(1+3*(cos(pi*k/20000)*cos(3*pi*k/20000)))+(2/3)*(cos(3*pi*k/200000)*cos(9*pi*k/200000)*cos(9*pi*k/100000))
}

R <- function(k) {
  (1/32)+(1/15)*(sin(37*pi*k/10000))*((sin(pi*k/10000))+(3/2)*(cos(pi*k/20000)))
}

parrot <- data.frame(a = A(k), b = B(k), r = R(k))

q <- ggplot() +
  geom_circle(aes(x0 = a, y0 = b, r = r), 
              data = parrot,
             n=30) + 
  coord_fixed() +
  theme_void()
q

parrot plotted with ggplot

Any help would be very much appreciated. Cartesian coords already applied as [explained here] (https://www.wikiwand.com/en/Hamid_Naderi_Yeganeh). From the visual point of view, it seems like the function is plotted properly but the "view" on it needs to be changed...

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文