[OpenLayers-Users] Point in parrallel with line formula

newbie shai_mus at hotmail.com
Fri May 1 12:29:48 EDT 2009


Dear Chris, 
              My data is in Latitude/Longitude. Ok I have used the java
sample code giving in the exercise. Only thing now I need to confirm is that
what is distance output in wat format ? Thank you.

Chris Adams wrote:
> 
> For the second part, you use this equation first, to find 'u':
> 
> http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/pointline2.gif
> (Where (x1,y1)-(x2,y2) is the line, and (x3,y3) is the point)
> 
> Then, you use this equation:
> 
> x = x1 + u (x2 - x1)
> y = y1 + u (y2 - y1)
> 
> to calculate the new point (x,y)
> 
> Then you have to use some distance equation, to find the distance 
> between (x3,y3) and (x,y).
> 
> Is your data in Latitude/Longitude? or Spherical Mercator? or something 
> else?
> 
> newbie wrote:
>> Dear Chris,
>>               So once I have I have decide whether is +1 or -1 then I
>> must
>> apply the other formula. So must I still apply the first formula to
>> decide
>> +1 or -1 or can I just go to the second formula. Secondly I still cant
>> really see the implementation of the formula. So is there any example
>> implementation of this formula cause I dont know to how to get the answer
>> in
>> metres? Thank you.
>>
>> Chris Adams wrote:
>>   
>>> +1 means to the left
>>> -1 means to the right
>>>
>>> before calling the 'ccw' function, you'll want to order p0 and p1 so 
>>> that p0 has the smaller latitude
>>>
>>> To get the distance on the left or right, use the formula linked from my 
>>> second response. It finds the closest point, on the line to the other 
>>> point, and then you need to take the distance between the two. If you 
>>> use Pythagorean theorem, it will give you distance in whatever 
>>> measurement  the projection of your map is in.
>>>
>>> newbie wrote:
>>>     
>>>> Dear Chris, I am a bit confuse. So the d will be in what measurement 
>>>> is it meter or km ? Then if is + or - what is the difference too. 
>>>> Thank you.
>>>>
>>>>     Chris Adams wrote:
>>>>     Here's a C++ function (Should be easy to convert to JavaScript) /*
>>>>     Taken from Robert Sedgewick, Algorithms in C++ */ /* returns
>>>>     whether, in traveling from the first to the second to the third
>>>>     point, we turn counterclockwise (+1) or not (-1) */ int ccw( Point
>>>>     p0, Point p1, Point p2 ) { int dx1, dx2, dy1, dy2; dx1 = p1.x -
>>>>     p0.x; dy1 = p1.y - p0.y; dx2 = p2.x - p0.x; dy2 = p2.y - p0.y; if
>>>>     (dx1*dy2 > dy1*dx2) return +1; if (dx1*dy2 < dy1*dx2) return -1;
>>>>     if ((dx1*dx2 < 0) || (dy1*dy2 < 0)) return -1; if ((dx1*dx1 +
>>>>     dy1*dy1) < (dx2*dx2 + dy2*dy2)) return +1; return 0; } >From this
>>>>     post on GameDev.net
>>>>     http://www.gamedev.net/community/forums/topic.asp?topic_id=457450
>>>>     Note it will also return 0 if the point is precisely on the line.
>>>>     The deals with turn directions, so it depends on the ordering of
>>>>     the points on the line. To get around this, you'll want to swap p0
>>>>     and p1, if if p1 is below p0. (If p1's latitude is smaller than
>>>>     p0's) newbie wrote: > Dear All, > Just say I got a pair of lat and
>>>>     long p1 and p2 and I draw a line > based on both the points. So
>>>>     now I want to know if a particular point in the > parallel range
>>>>     of say 50m either on left or right sides of the line. How can > I
>>>>     decide this what is the formula please ? >
>>>>     _______________________________________________ Users mailing list
>>>>     Users at openlayers.org http://openlayers.org/mailman/listinfo/users
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>> View this message in context: Re: Point in parrallel with line formula 
>>>> <http://n2.nabble.com/Point-in-parrallel-with-line-formula-tp2742247p2746662.html>
>>>> Sent from the OpenLayers Users mailing list archive 
>>>> <http://n2.nabble.com/OpenLayers-Users-f1822463.html> at Nabble.com.
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at openlayers.org
>>>> http://openlayers.org/mailman/listinfo/users
>>>>   
>>>>       
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>
>>>     
>>
>>   
> 
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Point-in-parrallel-with-line-formula-tp2742247p2754090.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list