Hi again,

Working with my real data and not with the little example i sent to the list i 
discovered that segm_distance function from package "pracma" does not converge 
to 0 in all cases, even if i increase the number of iteration to 10,000 for 
example. It seems that it depends on the "initialization" point - most like a 
minimization function. 

So my thanks  go to Don who's suggestion works for the real data as well 
without any problems - so far ;-) He suggested to use the function crossing.psp 
from package "spatstat".

Thanks again to all who have answered and helped to solve my problem. I 
certainly learned few new things.

Monica

 



> From: macque...@llnl.gov
> To: pisican...@hotmail.com
> CC: r-help@r-project.org
> Date: Wed, 23 Nov 2011 14:03:42 -0800
> Subject: Re: [R] x, y for point of intersection
> 
> The function crossing.psp() in the spatstat package might be of use.
> Here's an excerpt from its help page:
> 
> crossing.psp             package:spatstat              R Documentation
> Crossing Points of Two Line Segment PatternsDescription:
> Finds any crossing points between two line segment patterns.
> Usage:
> crossing.psp(A,B)
> -Don
> 
> 
> -- 
> Don MacQueen
> 
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
> 
> 
> 
> 
> 
> On 11/22/11 12:48 PM, "R. Michael Weylandt <michael.weyla...@gmail.com>"
> <michael.weyla...@gmail.com> wrote:
> 
> >If it's a one off, the identify() function might be of help -- if you
> >need something algorithmic it's harder due to floating point stuff and
> >sampling frequencies. Let me know if that's the case.
> >
> >Michael
> >
> >On Nov 22, 2011, at 3:40 PM, Monica Pisica <pisican...@hotmail.com> wrote:
> >
> >> 
> >> 
> >> 
> >> Hi everyone,
> >> 
> >>  
> >> 
> >> I am trying to get a point of intersection between a
> >> polyline and a straight line ©.. and get the x and y coordinates of
> >>this point.
> >> For exemplification consider this:
> >> 
> >>  
> >> 
> >>  
> >> 
> >> set.seed(123)
> >> 
> >>  
> >> 
> >> k1 <-rnorm(100, mean=1.77, sd=3.33)
> >> 
> >>  k1 <- sort(k1)
> >> 
> >> q1 <- rnorm(100, mean=2.37, sd=0.74)
> >> 
> >> q1 <- sort(q1, decreasing = TRUE)
> >> 
> >> plot(k1, q1, xlim <- c((min(k1)-5), (max(k1)+5)),
> >> type="l")
> >> 
> >>  
> >> 
> >> ya <- 2
> >> 
> >> xa = -5
> >> 
> >> yb=4
> >> 
> >> xb=12
> >> 
> >>  
> >> 
> >> lines(c(xa, xb), c(ya, yb), col = 2)
> >> 
> >>  
> >> 
> >> # I want to get the x and y coordinates of the
> >> intersection of the 2 lines ©.
> >> 
> >>  
> >> 
> >> m <- (ya-yb)/(xa-xb)
> >> 
> >> b <- ya-m*xa
> >> 
> >> ln <- loess(q1~k1)
> >> 
> >> lines(ln)
> >> 
> >>  
> >> 
> >> It is clear that the x, y will satisfy both linear
> >> equations, y = m*x + b and the ln polyline ©.. but while I can
> >>visualize the
> >> equation of the straight line ­ I have problems with the polyline. I
> >>will appreciate
> >> any ideas to solve this problem. I thought it a trivial solution but it
> >>seems I
> >> cannot see it.
> >> Thanks,
> >> Monica
> >> 
> >> 
> >>                 
> >> ______________________________________________
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >>http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> >______________________________________________
> >R-help@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
> 
                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to