TheSwamp

Code Red => .NET => Topic started by: nobody on September 20, 2016, 09:54:57 PM

Title: Checking for Perpendicular
Post by: nobody on September 20, 2016, 09:54:57 PM
Maybe I'm just tired but shouldn't this return true if my two points are perpendicular to the polyline?

Code - C#: [Select]
  1.      private static bool ninetycheck(Point3d pt1, Curve curve)
  2.         {
  3.             Editor MyEditor = Application.DocumentManager.MdiActiveDocument.Editor;
  4.  
  5.             Matrix3d mat = MyEditor.CurrentUserCoordinateSystem;
  6.             Point3d basept = pt1.TransformBy(mat);
  7.             Point3d pt = curve.GetClosestPointTo(basept, false);
  8.             Vector3d v3d = basept.GetVectorTo(pt);
  9.             Vector3d derv3d = curve.GetFirstDerivative(pt);
  10.             if (v3d.IsPerpendicularTo(derv3d))
  11.             {
  12.                 return true;
  13.             }
  14.        
Title: Re: Checking for Perpendicular
Post by: MickD on September 20, 2016, 11:47:35 PM
Just flying past with a quick thought...

Have you tried normalising the vectors first?
Title: Re: Checking for Perpendicular
Post by: nobody on September 21, 2016, 10:00:46 AM
Just flying past with a quick thought...

Have you tried normalising the vectors first?

Thanks Mick...will give that a shot
Title: Re: Checking for Perpendicular
Post by: Bryco on September 22, 2016, 08:20:55 PM
And add a tolerance