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.


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

  • +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

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

  • The polyline can contain more than one line segments, in which case I don't think this solution will stand under certain conditions. – masimplo 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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