• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónb49d1bf49a379bfc69962211774c1f1918cca8a3 (tree)
Tiempo2023-03-05 04:43:34
AutorLorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

I merged some heads.

Cambiar Resumen

Diferencia incremental

diff -r 3f40b4513eb5 -r b49d1bf49a37 R-codes/attractor1.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/R-codes/attractor1.R Sat Mar 04 20:43:34 2023 +0100
@@ -0,0 +1,87 @@
1+rm(list=ls())
2+
3+library(Rcpp)
4+library(ggplot2)
5+library(dplyr)
6+library(purrr)
7+library(scattermore)
8+library(tictoc())
9+library(viridis)
10+library(scales)
11+
12+tic()
13+
14+opt = theme(legend.position = "none",
15+ panel.background = element_rect(fill="black"),
16+ axis.ticks = element_blank(),
17+ panel.grid = element_blank(),
18+ axis.title = element_blank(),
19+ axis.text = element_blank())
20+
21+
22+
23+## #bedhead
24+cppFunction('DataFrame createTrajectory(int n, double x0, double y0,
25+ double a, double b) {
26+ // create the columns
27+ NumericVector x(n);
28+ NumericVector y(n);
29+ x[0]=x0;
30+ y[0]=y0;
31+ for(int i = 1; i < n; ++i) {
32+ x[i] = sin(x[i-1]*y[i-1]/b)*y[i-1]+cos(a*x[i-1]-y[i-1]);
33+ y[i] = x[i-1]+sin(y[i-1])/b;
34+ }
35+ // return a new data frame
36+ return DataFrame::create(_["x"]= x, _["y"]= y);
37+ }
38+ ')
39+
40+a=1.2
41+b=0.15
42+
43+df3=createTrajectory(4000000, 1, 1, a, b)
44+
45+#something new
46+#color by dist from origin
47+eu_dist <- function(x1, y1, x2, y2) {
48+ sqrt((x1-x2)^2 + (y1-y2)^2)
49+}
50+
51+
52+df3$dist <- map2_dbl(df3$x, df3$y, ~eu_dist(.x, .y, 0, 0))
53+
54+pulse_pal <- colorRampPalette(c("#FE1BE1", "#A300FF", "#57F7F5", "#57F7F5", "#57F7F5", "#57F7F5"))
55+pulse_pal2 <- colorRampPalette(c("#FE1BE1", "#FE1BE1", "#57F7F5", "#57F7F5", "#57F7F5", "#57F7F5", "#57F7F5"))
56+pulse_pal3 <- colorRampPalette(c("#FE1BE1", "#AA1BFE", "#57F7F5", "#57F7F5", "#57F7F5"))
57+pulse_pal4 <- colorRampPalette(c("#AA1BFE", "#57F7F5", "#57F7F5"))
58+
59+#clip outer points
60+xmax <- max(df3$x)/2.5
61+xmin <- min(df3$x)/2.5
62+ymax <- max(df3$y)/2.5
63+ymin <- min(df3$y)/2.5
64+
65+df3_clip <- df3 |>
66+ filter(x > xmin & x < xmax) |>
67+ filter(y > ymin & y < ymax) |>
68+ as_tibble() ## |>
69+ ## mutate(dist=rescale(dist))
70+
71+print("df3clip ready")
72+
73+#plot
74+ggplot(df3_clip, aes(x, y)) +
75+ ## geom_point(aes(color = dist), shape=46, alpha=.01) +
76+ geom_scattermore(aes(color = dist), shape=46, alpha=.03) +
77+ scale_color_viridis(option="D")+
78+ ## scale_color_gradientn(colors=pulse_pal4(500)) +
79+
80+ opt
81+
82+ggsave("pulse.png", height=5000, width=5000, unit="px"
83+ )
84+
85+toc()
86+
87+sessionInfo()