[R] Intersection between circle and line?

Chris82 rubenbauar at gmx.de
Mon Sep 26 17:03:15 CEST 2011


Dear R users,

I am thinking about an easy and especially fast solution to calculate the
x,y coordinates of the interesection between the borders of the red circle
and the line.

short example:

plot(c(-3,0,3,9,21),c(-8,0,5,12,25))
draw.circle(0,0,radius=6,border="red",col=NA,lty=1,lwd=1)
x <- c(-12,-6,-1,0,13,21)
y <- c(-19,-10,-5,0,9,25)
plot(x,y)
require(plotrix)
draw.circle(0,0,radius=6,border="red",col=NA,lty=1,lwd=1)
lines(c(-12,-6,-1,13,21),c(-19,-10,-5,9,25),cex=2)


At the moment I am interpolating the points which gives the basis
coordinates of the line. I do this with approx() and then I check which
point is within the circle and which one is not. The probleme is, that this
method is not really exact and for my dataset it takes too much time.


Thanks.

With best regards

--
View this message in context: http://r.789695.n4.nabble.com/Intersection-between-circle-and-line-tp3844063p3844063.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list