drosofff
12/21/2016 - 6:01 PM

BrokenSun_colored.r

require("shape") # load Shapes package
x = runif(10000, 0, 99)
y = runif(10000, 0, 99)
plan = data.frame(x, y)
plan$dist2=sqrt((plan$x-60)^2 + (plan$y-60)^2)
plan$ang2 = ifelse(plan$y-60>0, acos(abs(plan$x-60)/plan$dist2),
    asin(abs(plan$x-60)/plan$dist2) ) # note that this formula "brakes" orientations
couleur = intpalette(c("red","yellow","darkblue"), numcol=100) # to range colors
plot(plan$x, plan$y, xlab="", ylab="", xlim=c(0,100), ylim=c(0,100), pch=20,
    col=couleur[1+(plan$dist2*100/max(plan$dist2))], cex=0.5)
segments(plan$x, plan$y,
    plan$x+(1 * cos(plan$ang2)), plan$y+(1 * sin(plan$ang2)),
    col=couleur[1+(plan$dist2*100/max(plan$dist2))], lwd=3 )