A_Skelton73
A_Skelton73

Reputation: 1190

Points of intersection in R

This might be a stupid question...

I've two vectors containing Y coords X is simply 1:8

I've added the lines to a plot area and would like to identify the point of intersection of the two lines.

Is there a default package to find this?

Thanks

Upvotes: 0

Views: 1009

Answers (1)

Carl Witthoft
Carl Witthoft

Reputation: 21492

The intersection of two lines is found analytically by solving the two linear equations which define the lines. I'll leave the math as an exercise to the OP.

If you want to use a very helpful and powerful package, you could read up on the package spatstat . Once you've converted your lines into psp objects, use spatstat:crossing.psp to find intersections.

Upvotes: 2

Related Questions