Khangharoth

January 10, 2007

Baisc Co-ordinate

Filed under: 3D Maths — khangharoth @ 1:11 pm

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!

Advertisements

1 Comment »

  1. This can be done simpler: If your line segment is from point A to B, and you want to find the distance to P, then

    1. Imagine a plane through A which is perpendicular to AB, and calculate the distance d of P to the plane. Do this by using the http://de.wikipedia.org/wiki/Hessesche_Normalform as this will give you not just a distance, but also a positive/negative sign which shows “how far along AB P lies”

    2. If d<0 or d greater the length of AB, then calculate the point distance to A (if d<0) or B. The solution on the page above is not 100% accurate in this case.

    3. If 0 <= d <= length_of_AB, then calculate length_of_AP and via Pythagoras the distance of P to the segment is sqrt(length_of_AP^2 + d^2)

    Comment by Richard — March 16, 2009 @ 10:28 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: