I want to get the actual value of the points in the circle. Can you tell me how to get them? Thanks!
> insiders [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE TRUE FALSE [49] FALSE TRUE On 4/22/06, Gabor Csardi <[EMAIL PROTECTED]> wrote: > > Fine, than just check every point like suggested below. > (whether (c1-x)^2+(c2-y)^2 < r^2) > and call 'symbols' to add the circle to the plot like this: > symbols(c1, c2, circles=r, inches=FALSE, add=TRUE) > > For example, if coords is a two column matrix of the coordinates of the > points: > > ################################ > coords <- matrix( runif(100), nc=2 ) > c1 <- c2 <- 0.5 > r <- 0.2 > > insiders <- apply(coords, 1, > function(co) (c1-co[1])^2+(c2-co[2])^2 < r^2) > plot(coords) > symbols(c1, c2, circles=r, inches=FALSE, add=TRUE) > ################################ > > 'insiders' will be a logical vector telling whether the points are inside > or > outside the circle. > > Gabor > > On Sat, Apr 22, 2006 at 02:16:38PM -0400, Jian Zhang wrote: > > Thanks! > > There are many points in our plot. I want to choose the points which > > distance to one point (e.g.(100,200)) is less than 10. > > And I want to draw a circle (radinus=10). The centre of the circle is > the > > point (100,200). > > > > > > On 4/22/06, Gabor Csardi <[EMAIL PROTECTED]> wrote: > > > > > >Hmmm, could you explain this a bit? > > >You want to add a circle to a plot? See the examples in help(symbols) > > > > > >Or you want to calculate the coordinates of the points on a circle? > > > > > >t <- seq(0,2*pi,length=100) > > >coords <- t(rbind( 10+sin(t)*2, 20+cos(t)*2)) > > >plot(coords) > > > > > >Here (10,20) is the center of the circle, and 2 is its radius. > > >If you set length to a bigger number you'll get smoother resolution. > > > > > >A points (x,y) is inside the circle if (c1-x)^2+(c2-y)^2 < r^2 > > >(c1, c2) is the center of the circle, r is its radius. > > > > > >Gabor > > > > > >On Sat, Apr 22, 2006 at 01:42:46PM -0400, Jian Zhang wrote: > > >> how to draw a circle (e.g. radius=10cm) of one point? > > >> And how to choose these points in the circle? > > >> Thanks! > > >> > > >> [[alternative HTML version deleted]] > > >> > > >> ______________________________________________ > > >> [email protected] mailing list > > >> https://stat.ethz.ch/mailman/listinfo/r-help > > >> PLEASE do read the posting guide! > > >http://www.R-project.org/posting-guide.html > > > > > >-- > > >Csardi Gabor <[EMAIL PROTECTED]> MTA RMKI, ELTE TTK > > > > > -- > Csardi Gabor <[EMAIL PROTECTED]> MTA RMKI, ELTE TTK > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > [[alternative HTML version deleted]] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
