Skip to content

Instantly share code, notes, and snippets.

@kohske
Created December 8, 2017 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohske/d618c8e8b1f3eb5fc6937c2b9b05ba0c to your computer and use it in GitHub Desktop.
Save kohske/d618c8e8b1f3eb5fc6937c2b9b05ba0c to your computer and use it in GitHub Desktop.
Reproducible Example of Curvature Blindness Illusion
# Reproducible Example of
# Curvature Blindness Illusion
# Kohske Takahashi, Chukyo University, Japan
# ref: http://journals.sagepub.com/doi/abs/10.1177/2041669517742178
library(grid)
grid.newpage()
# some params
NY = 48
height = 0.75
xd = 20
col1 = "gray70"
col2 = "gray30"
N = 500
x = seq(0, 1, length.out = N)
ys = (0:NY/NY)[rep(c(F,T,T,F), length.out=NY)]
di = rep(c(1,1,-1,-1), length.out = NY)
bd = 0.5
grid.rect(gp = gpar(fill = "gray50"))
grid.polygon(c(0, bd, 0), c(1, 1, 1-bd), gp = gpar(col=NA,fill = "white"))
grid.polygon(c(1-bd, 1, 1), c(0, bd, 0), gp = gpar(col=NA,fill = "black"))
for (i in 1:length(ys)) {
# all lines are sine wave!!
y = (sin(20*x*pi)+1)/100*height + ys[i]
id = di[i]*sin(40*(x)*pi)>0
id = cumsum(c(0, diff(id)) > 0)
id[id%%2==0] = NA
grid.lines(x, y, gp = gpar(col = col1, lwd = 3))
grid.polyline(x, y, id = id, gp = gpar(col = col2, lwd = 3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment