Author Topic: Checking for Perpendicular  (Read 1963 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Checking for Perpendicular
« 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.        
« Last Edit: September 20, 2016, 10:08:57 PM by Area51Visitor »

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Checking for Perpendicular
« Reply #1 on: September 20, 2016, 11:47:35 PM »
Just flying past with a quick thought...

Have you tried normalising the vectors first?
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Checking for Perpendicular
« Reply #2 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

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Checking for Perpendicular
« Reply #3 on: September 22, 2016, 08:20:55 PM »
And add a tolerance