Blender V2.61 - r43446

MT_Plane3.inl

Go to the documentation of this file.
00001 #include "MT_Optimize.h"
00002 
00003 
00004 GEN_INLINE
00005 MT_Plane3::
00006 MT_Plane3(
00007     const MT_Vector3 &a,
00008     const MT_Vector3 &b,
00009     const MT_Vector3 &c
00010 ){
00011     MT_Vector3 l1 = b-a;
00012     MT_Vector3 l2 = c-b;
00013 
00014     MT_Vector3 n = l1.cross(l2);
00015     n = n.safe_normalized();
00016     MT_Scalar d = n.dot(a); 
00017 
00018     m_co[0] = n.x();
00019     m_co[1] = n.y();
00020     m_co[2] = n.z();
00021     m_co[3] = -d;
00022 }
00023 
00027 GEN_INLINE
00028 MT_Plane3::
00029 MT_Plane3(
00030     const MT_Vector3 &n,
00031     const MT_Vector3 &p
00032 ){
00033     
00034     MT_Vector3 mn = n.safe_normalized();
00035     MT_Scalar md = mn.dot(p); 
00036 
00037     m_co[0] = mn.x();
00038     m_co[1] = mn.y();
00039     m_co[2] = mn.z();
00040     m_co[3] = -md;
00041 }
00042 
00043 
00047 GEN_INLINE
00048 MT_Plane3::
00049 MT_Plane3(
00050 ):
00051     MT_Tuple4()
00052 {
00053     m_co[0] = MT_Scalar(1);
00054     m_co[1] = MT_Scalar(0);
00055     m_co[2] = MT_Scalar(0);
00056     m_co[3] = MT_Scalar(0);
00057 }
00058 
00063 GEN_INLINE
00064     MT_Vector3
00065 MT_Plane3::
00066 Normal(
00067 ) const {
00068     return MT_Vector3(m_co[0],m_co[1],m_co[2]);
00069 }
00070 
00075 GEN_INLINE
00076     MT_Scalar
00077 MT_Plane3::
00078 Scalar(
00079 ) const {
00080     return m_co[3];
00081 }
00082 
00083 GEN_INLINE
00084     void
00085 MT_Plane3::
00086 Invert(
00087 ) {
00088     m_co[0] = -m_co[0];
00089     m_co[1] = -m_co[1];
00090     m_co[2] = -m_co[2];
00091     m_co[3] = -m_co[3];
00092 }
00093 
00094 
00099 GEN_INLINE
00100     MT_Plane3 &
00101 MT_Plane3::
00102 operator = (
00103     const MT_Plane3 & rhs
00104 ) {
00105     m_co[0] = rhs.m_co[0];
00106     m_co[1] = rhs.m_co[1];
00107     m_co[2] = rhs.m_co[2];
00108     m_co[3] = rhs.m_co[3];
00109     return *this;
00110 }
00111 
00116 GEN_INLINE
00117     MT_Scalar
00118 MT_Plane3::
00119 signedDistance(
00120     const MT_Vector3 &v
00121 ) const {
00122     return Normal().dot(v) + m_co[3];
00123 }
00124 
00125 
00126 
00127 
00128