Community of VE/MapPoint Users and Developers
This is a discussion on Points in a straight line within the MapPoint 2006/2009 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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Points in a straight line Does anyone know what the equation might be to do this. |
| ||||
|
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 Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
|
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 |
| ||||
|
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 Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
|
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. |
| ||||
|
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 Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
![]() |
| Tags |
| line, points, straight |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to draw a line between points | bobil | MapPoint 2006/2009 Discussion | 2 | 05-25-2006 09:23 AM |
| draw simple line between points | Anonymous | MapPoint 2006/2009 Discussion | 0 | 07-27-2004 05:15 AM |
| Railways - why can't they be straight! | Mossoft | MapPoint 2006/2009 Discussion | 1 | 04-14-2004 08:05 AM |
| How can I create a line between two line with VB6 | Anonymous | MapPoint 2006/2009 Discussion | 0 | 04-29-2003 06:44 PM |
| As I draw a line and then a pushpin on that line, .... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 07-16-2002 09:35 AM |