Clifford Attractors

library(Rcpp)
library(ggplot2)
library(dplyr)

opt = theme(legend.position  = "none",
            panel.background = element_rect(fill="white"),
            axis.ticks       = element_blank(),
            panel.grid       = element_blank(),
            axis.title       = element_blank(),
            axis.text        = element_blank())

cppFunction('DataFrame createTrajectory(int n, double x0, double y0, 
            double a, double b, double c, double d) {
            // create the columns
            NumericVector x(n);
            NumericVector y(n);
            x[0]=x0;
            y[0]=y0;
            for(int i = 1; i < n; ++i) {
            x[i] = sin(a*y[i-1])+c*cos(a*x[i-1]);
            y[i] = sin(b*x[i-1])+d*cos(b*y[i-1]);
            }
            // return a new data frame
            return DataFrame::create(_["x"]= x, _["y"]= y);
            }
            ')

a=-1.24458046630025
b=-1.25191834103316 
c=-1.81590817030519 
d=-1.90866735205054

df=createTrajectory(10000000, 0, 0, a, b, c, d)

png("Clifford.png", units="px", width=1600, height=1600, res=300)
ggplot(df, aes(x, y)) + geom_point(color="black", shape=46, alpha=.01) + opt
dev.off()
Clifford.png

https://fronkonstin.com/2017/11/07/drawing-10-million-points-with-ggplot-clifford-attractors/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,581评论 2 45
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,959评论 0 23
  • 1.“我们从来没有出过门!” 女人的真实意思是:“我特别希望能和你出去转一转,找些有趣的消遣。我们在一起总是特别开...
    wwwbb阅读 1,718评论 4 2
  • 文/悠逸安然 天空憋了一天的情绪,终于在傍晚时分,将心里所有不快通通宣泄出来。雪花沾染着空气中的尘埃,并不像我们想...
    悠逸安然阅读 1,840评论 4 20
  • 前天一场大雪降临,二月时节,真真的春雪。我属于一看到雪就有一种莫名的兴奋之感,尤其是去年一冬天都不曾看到过那么大的...
    黄小蚁阅读 246评论 0 2