| 814 | //----------------------------------------------------------------------------- |
| 815 | |
| 816 | void mShortestSegmentBetweenLines( const Line &line0, const Line &line1, LineSegment *outSegment ) |
| 817 | { |
| 818 | // compute intermediate parameters |
| 819 | Point3F w0 = line0.origin - line1.origin; |
| 820 | F32 a = mDot( line0.direction, line0.direction ); |
| 821 | F32 b = mDot( line0.direction, line1.direction ); |
| 822 | F32 c = mDot( line1.direction, line1.direction ); |
| 823 | F32 d = mDot( line0.direction, w0 ); |
| 824 | F32 e = mDot( line1.direction, w0 ); |
| 825 | |
| 826 | F32 denom = a*c - b*b; |
| 827 | |
| 828 | if ( denom > -0.001f && denom < 0.001f ) |
| 829 | { |
| 830 | outSegment->p0 = line0.origin; |
| 831 | outSegment->p1 = line1.origin + (e/c)*line1.direction; |
| 832 | } |
| 833 | else |
| 834 | { |
| 835 | outSegment->p0 = line0.origin + ((b*e - c*d)/denom)*line0.direction; |
| 836 | outSegment->p1 = line1.origin + ((a*e - b*d)/denom)*line1.direction; |
| 837 | } |
| 838 | } |
| 839 | |
| 840 | //----------------------------------------------------------------------------- |
| 841 |
no test coverage detected