Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 7 of 7

Points in a straight line

This is a discussion on Points in a straight line within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have a number of lines drawn on a map and for the purposes of a program I am writting ...

  1. #1
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103

    Points in a straight line

    I have a number of lines drawn on a map and for the purposes of a program I am writting I need to get about 10 coordinates along the length of each line, I can get the coordinates at the end of each line but, not being particularly great at maths!!!, I cant work out how to get coordinates along the length of the line.

    Does anyone know what the equation might be to do this.

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    Is this a straight line? If so:

    You can derive it from the principle of like triangles. Or from vector addition.

    Let your endpoints be A and B
    A = (x1,y1)
    B = (x2, y2)

    Let Delta = A - B
    ie. Delta_X = x1-x2 and Delta_Y = y1-y2

    Point P on line = (xp,yp)

    xp = x1 + L * Delta_X
    yp = y1 + L * Delta_Y

    L = Real number in the range 0...1
    0 gives A, 1 gives B
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Thanks for your help, what i'm trying to do is plot positions within a freeform shape by using horizontal scan lines from left to right and as we move across the scan lines I need to be able to know if I have crossed a line in the shape, if i cross an odd number of lines I must be inside the shape, an even number and i'm outside.

    Therefore I need to be able to work out if the x position on a particular y scan line has crossed a line in the shape so I think what I need to know is the x position on the shape for a given value of y.

    I already know the coordinates for all the points on the shape.

    I think this makes sense but as I said I never was any good at maths! Do you think you could help by giving me an 'idiots guide' on how I should go about doing this. Possibly using an example

    Lat, Lon

    Start point of line 50.83386, -0.1674
    End Point 50.8335, -0.1688

    So now I want to find the x(longitude) position on the line where y(latitude) = 50.8337

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    I think there was an error in my original reply - the sign of Delta is reversed.


    For what you're after a "Method of Similar Triangles" is probably more appropriate but requires a diagram to be clear. Mathematically it is the same though.

    Line A-B, what is X for a particular Y?
    A=Ax,Ay
    B=Bx,By

    Like triangles gives:
    (Ax-Bx) / (Ay-By) = ( X - Bx) / ( Y - By)

    Note: Ay=By will give an error - you need to check for this.
    As will Y = By

    Re-arranging,

    (X-Bx) = (Ax-Bx) * (Y-By) / (Ay-By)

    => X = Bx + (Ax-Bx) * (Y-By) / (Ay-By)


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Thanks for your help, i'll give this a try and i'll keep you posted

  6. #6
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Thanks for your help again, you will be pleased to here that using that equation I have now managed to write the code for working out points (addresses) within a freeform shape, this has saved me and others hours of extra work.

    Thanks again for you help.

  7. #7
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    Glad to be of help!

    Really it is just a form of linear interpolation - I've it used on everything from geometric problems to interpolating seismic velocities near salt in sedimentary basins such as the Gulf of Mexico and the North Sea!


    btw, If you have any further problems, I'm available for hire...


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. how to draw a line between points
    By bobil in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 05-25-2006, 09:23 AM
  2. draw simple line between points
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-27-2004, 05:15 AM
  3. Railways - why can't they be straight!
    By Mossoft in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-14-2004, 08:05 AM
  4. How can I create a line between two line with VB6
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-29-2003, 06:44 PM
  5. As I draw a line and then a pushpin on that line, ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-16-2002, 09:35 AM

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
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96