00001 // llline.h 00024 #ifndef LL_LINE_H 00025 #define LL_LINE_H 00026 00027 #include <iostream> 00028 #include "stdtypes.h" 00029 #include "v3math.h" 00030 00031 const F32 DEFAULT_INTERSECTION_ERROR = 0.000001f; 00032 00033 class LLLine 00034 { 00035 public: 00036 LLLine(); 00037 LLLine( const LLVector3& first_point, const LLVector3& second_point ); 00038 virtual ~LLLine() {}; 00039 00040 void setPointDirection( const LLVector3& first_point, const LLVector3& second_point ); 00041 void setPoints( const LLVector3& first_point, const LLVector3& second_point ); 00042 00043 bool intersects( const LLVector3& point, F32 radius = DEFAULT_INTERSECTION_ERROR ) const; 00044 00045 // returns the point on this line that is closest to some_point 00046 LLVector3 nearestApproach( const LLVector3& some_point ) const; 00047 00048 // returns the point on this line that is closest to other_line 00049 LLVector3 nearestApproach( const LLLine& other_line ) const; 00050 00051 friend std::ostream& operator<<( std::ostream& output_stream, const LLLine& line ); 00052 00053 // returns 'true' if this line intersects the plane 00054 // on success stores the intersection point in 'result' 00055 bool intersectsPlane( LLVector3& result, const LLLine& plane ) const; 00056 00057 // returns 'true' if planes intersect, and stores the result 00058 // the second and third arguments are treated as planes 00059 // where mPoint is on the plane and mDirection is the normal 00060 // result.mPoint will be the intersection line's closest approach 00061 // to first_plane.mPoint 00062 static bool getIntersectionBetweenTwoPlanes( LLLine& result, const LLLine& first_plane, const LLLine& second_plane ); 00063 00064 const LLVector3& getPoint() const { return mPoint; } 00065 const LLVector3& getDirection() const { return mDirection; } 00066 00067 protected: 00068 // these are protected because some code assumes that the normal is 00069 // always correct and properly normalized. 00070 LLVector3 mPoint; 00071 LLVector3 mDirection; 00072 }; 00073 00074 00075 #endif