-
[HELP] Lines
Line a: point(xa1,ya1) to point(xa2,ya2)
and
Line b: point(xb1,yb1) to point(xb2,yb2)
how can i know these two line intersect each other and at what point?
-
Senior Member
Here's a pretty good treatment of the problem.
http://astronomy.swin.edu.au/~pbourk...ry/lineline2d/
- Jim
-
if you want to first check they intercect then check that they aren't parallel:
gradient a:
(ya2-ya1)/(xa2-xa1)
gradient b:
(yb2-yb1)/(xb2-xb1)
these two values should be different
-
i want to see if these two line intersect between their end points.
-
check the gradients then refer to jbum's link if they are not parallel or you can just get there equations and solve simultaneously if you're just doing it by hand
then check that the point of intersection (xi) is such that either xa1 < xi < xa2 or xa1 > xi > xa2 and so on for both x and y and both lines
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|