Thursday, September 29, 2005

Math: Distance between two lines

เยี่ยมมาก คิดอยู่ตั้งนานว่าจะ proof ทฤษฎีพื้นฐานนี่ได้ยังไง ในที่สุดก็เจอ

Objective: Given two straight lines in 3D:
  • line 1:    r = a + t*b
  • line 2:    r = p  +s*q

    Show that the distance between those two lines are |(a - p).u|
    where u is a unit vector given by b x q / |b x q|.
The distance is the length of line segment that perpendicular to both line 1 and 2. Thus if we can find the length of that line segment we are done. So there are two subproblems now:
  1. Finding direction of the line segment
  2. Finding the length of the line segment that bridge line 1 and 2
To find direction of the line segment cross product can be used because output from cross product is a vector perpendicular to both input vectors. In other word, b x q gives out the direction we want.

To find the length, scalar projection can be applied. If we know a vector that bridges the two lines (in this case it is a - p), we can find the distance between those two lines by calculating scalar projection on the perpendicular vector. Remember that the distance is actually |a - p| cos theta where theta is an angle between (a - p) and the perpendicular vector.

The scalar projection is |a - p|cos theta = | (a - p) . (b x q) | / | b x q| = | (a - p) . u|.

Q.E.D.

1 comment:

Anonymous said...

pinyotae your Math: Distance between two lines was a healthy read. We need more of this in the internet community and articles about strokes, strokes, strokes and strokes are other health issues that you might consider. Our strokes is related to health issues and topics. Keep up the great articles and subject matter.