[OpenLayers-Users] Point in parrallel with line formula

newbie shai_mus at hotmail.com
Thu Apr 30 08:05:36 EDT 2009


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: http://n2.nabble.com/Point-in-parrallel-with-line-formula-tp2742247p2746662.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090430/bc8f103d/attachment.html


More information about the Users mailing list