A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [HELP] Lines

  1. #1

    [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?

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Here's a pretty good treatment of the problem.

    http://astronomy.swin.edu.au/~pbourk...ry/lineline2d/

    - Jim

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    486
    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

  4. #4
    i want to see if these two line intersect between their end points.

  5. #5
    Senior Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    486
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center