Author Topic: On which side of a polyline?  (Read 2434 times)

0 Members and 1 Guest are viewing this topic.

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
On which side of a polyline?
« on: July 11, 2013, 05:23:43 AM »
Is it possible to check on which side of a selected polyline a given point is?

I can check the closest point on the polyline and get the distance between the given point and the closest (perpendicular) point on the polyline but that distance value is always positive. I would like a negative disance if the point is on the left-hand side and positive on the right-hand side.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

bargool

  • Guest
Re: On which side of a polyline?
« Reply #1 on: July 11, 2013, 05:34:20 AM »
You can get closest point on polyline
Method GetClosestPointTo of the polyline object. Then use vectors etc..

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: On which side of a polyline?
« Reply #2 on: July 11, 2013, 06:05:08 AM »
Hi,

Here's a little extension method which strictly checks for left or right.

Code - C#: [Select]
  1.     public static class PolylineExtension
  2.     {
  3.         public static double GetSignedDistanceTo(this Polyline pline, Point3d pt)
  4.         {
  5.             Point3d closest = pline.GetClosestPointTo(pt, false);
  6.             Vector3d deriv = pline.GetFirstDerivative(pline.GetParameterAtPoint(closest));
  7.             return deriv.GetAngleTo(closest.GetVectorTo(pt), pline.Normal) > Math.PI ?
  8.                 pt.DistanceTo(closest) : -pt.DistanceTo(closest);
  9.         }
  10.     }

If the issue is about polyline offset side, you can see this reply and the related following ones.
« Last Edit: July 11, 2013, 06:10:15 AM by gile »
Speaking English as a French Frog

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: On which side of a polyline?
« Reply #3 on: July 11, 2013, 07:07:35 AM »
Really cool Gile!  :)

I was thinking in more complex solutions but I did learn again from your code! Thank you :-)
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.