Consulting

Results 1 to 4 of 4

Thread: Line intersection - with a difference

  1. #1
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location

    Line intersection - with a difference

    I have been working on a problem and through all of my research I have been unable to find an existing resolution. I do not have the required math knowledge to produce an elegant solution.

    There are several examples of working (and very elegant) line - line intersections with either complete lines or line segment (see links) :

    https://dl.dropboxusercontent.com/u/..._Corrected.xls

    https://dl.dropboxusercontent.com/u/...0Intersect.xls

    https://dl.dropboxusercontent.com/u/...tersection.xls

    https://dl.dropboxusercontent.com/u/...tersection.xls

    The problem I have is illustrated using the attached image. There is a defined line, starting at L1 (x,y) and finishing at L2 (x,y). There is no second line - instead there are the coordinates for another point (effectively L3) and an axis or angle of travel. I need to calculate the distance to and coordinates of the intersect if the point L3 was continued along the axis / angle of travel.

    Line - Point intersection at an angle.jpg

    It would also be useful to get the coordinates of a position when provided with an origin, a bearing and a distance e.g. x, y with a distance of 10m on a bearing of 195 degrees arrives you at x, y? This is effectively the same function, except the distance is defines vs calculating the distance and x, y of the intersection

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    I think this is right -- maybe not perfect but neither's my math anymore

    P1 and P2 are the line end points of the first line

    P3 is the other point

    I used polar coordinates to get a P4 on the unit circle and this was the second point on the second line

    So the intersection of the lines P1-P2 and P3-P4 gave me P5

    The pythogrian theorem gave me the distance from P5 to P3

    Good luck and hope this was a little helpful (and like I said I'm very rusty with this stuff)
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location
    Fantastic I will take a look and see. Works fine so far

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    If the logic is correct, a VBA solution is most likely possible by making a User Defined Function that you could use as a work sheet formula
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •