As i am writing Brep Datastructure and operations on them , i had to come up with some basic 3D maths util classes,
like rotation of a Vector about a given Axis .
Also basic classes for primitves say Line : From which i can compute distance , intersection pt etc.
I am using VecMath Libs : Its a Open-Source 3D Math util library resulted as sub-project in Java3D devlopent .
Can be downloaded from this link vecmath.
As of now i am uploading three java files.
Today while implementing Breps in my dataStructure i got a interesting problem to solve .
Basically needed to figure out the distance of a Line -Segment from a specified point so that i can see which is the closet edge in a Object.
Its a Line Segemnt and not whole Line from which we need to find distance . So perpendicular distance is not the smallest distance if the perpendicular does not fall on that segment .So how to solve this.
Well the solution i was able to came up is :
1 ) Make a Plane from two points of LineSegment and specified Pt given .
2) On this plane make two Lines Passing through the end Points of the Segemnt and Perpendicular to it.
3) Now say D is the distance between two end Points of the Segment.
And D1 =Distance of Specified Pt from first Perpendicular.
D2=Distance of Specified Pt from second Perpendicular.
4) If D is greater than D1 and D2 . Than minimum distance of that Specified pt will be Perpendicluar from this point on
the Line Equation.
5 ) Otherwise shorter of the distance between Specified pt and two pts of the Segment is the minimum distance.
Not Bad huh!