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,513評論 2 45
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,868評論 0 23
  • 1.“我們從來沒有出過門!” 女人的真實意思是:“我特別希望能和你出去轉一轉,找些有趣的消遣。我們在一起總是特別開...
    wwwbb閱讀 1,681評論 4 2
  • 文/悠逸安然 天空憋了一天的情緒,終于在傍晚時分,將心里所有不快通通宣泄出來。雪花沾染著空氣中的塵埃,并不像我們想...
    悠逸安然閱讀 1,835評論 4 20
  • 前天一場大雪降臨,二月時節,真真的春雪。我屬于一看到雪就有一種莫名的興奮之感,尤其是去年一冬天都不曾看到過那么大的...
    黃小蟻閱讀 245評論 0 2