Re: [R] Semi-random movement inside a circle

2008-12-18 Thread Yihui Xie
Hi, I've simplified the "bouncing off" part as choosing another place to go (with no consideration of the bouncing details): ## set.seed(1234) par(pty = "s", pch = 19, ann = FALSE, xaxt = "n", yaxt = "n", bty = "n") theta = seq(0, 2 * pi, length = 512) n = 20 nmax = 500 x = runif(n, -1, 1) y

[R] Semi-random movement inside a circle

2008-12-15 Thread Struve, Juliane
Dear list, I am trying to program semi-random movement within a circle, with no particles leaving the circle. I would like them to bounce back when they come to close to the wall, but I don't seem to be able to get this right. Would somebody kindly give me a hint ? This is my code so far, the