Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In ArcGIS engine I have a polyline with From and To points. I also have a Point. How can I determine if the point is located on the right or left of the line on the plane considering the direction of the line?

I thought of using MeasurementTool to get a point from the line and the point to be related and find the angle between them in relation with the azimuth of the line, but there lies the problem of which point from the line I should choose.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

I'd use IPolyCurve.QueryPointAndDistance. The bRight value get set true if the point is on the right side of the polyline.

share|improve this answer
    
+1 The advantages of this solution, compared to writing one's own brute-force code, include not having to do all the tricky work involved (which may look simple to the uninitiated but involves lots of traps involving special cases and numerical inaccuracy) and the likelihood that the underlying .QueryPointAndDistance algorithms use efficient data structures and algorithms (such as a line-sweep algorithm), which will scale well. –  whuber Sep 21 '11 at 15:28
add comment

I think a possible solution could be to calculate the angle of the from and to points with a plane based on min max x, and then calculate the same angle using the from point, to the point in question. then work out which angle is bigger.

Or a bastardisation of that, taking into account errors etc. Standard trig

share|improve this answer
    
The polyline can contain more than one line segments, in which case I don't think this solution will stand under certain conditions. –  mxa055 Sep 21 '11 at 10:24
    
So then apply the theory on a line by line basis, within the polyline. I have a neat and clean algorithm which takes a start point, end point, and a given, and it then gives you the point on the line, if it is on the line. But, ostensibly, you can find out the angles very easily, even traversing the lines within the polyline. –  Hairy Sep 21 '11 at 10:51
    
I think the a way for this to work, is traverse the polyline, and then work out the perpendicular line from the point in question, to the plane of the line segment you are currently trying. If the point is on the line, then it is a simple calculation to work out where it is, in relation to the line, if it isn't, go to the next line segment in the polyline. That way, you cna find out which line segment you need to calculate and the details you are looking for. –  Hairy Sep 21 '11 at 11:01
1  
@Hairy There is no guarantee that such a segment exists. You could easily imagine a situation where no segment intersects the perpendicular line (e.g.: [> .], the '>' being the polyline and '.' being the point) –  mkadunc Sep 21 '11 at 12:58
    
@mkadunc, absolutely, but for a developer, this is simple error checking. There are, also, other areas of concern too, but the remise is the same. Personally, there are many ways to crack this egg, for example, to simply create a line perpendicular to the main gradient and catch the intersection. But the point remains, it is a, fairly, simple trig exercise. –  Hairy Sep 21 '11 at 14:02
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.