![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsTriangle.cpp 00003 00004 Triangle class is a class for 3D Triangle composed of three Vector3<T> as their 00005 vertices. 00006 00007 Example: 00008 2-------1 00009 \ | 00010 \ | 00011 \ | 00012 \ | 00013 \ | 00014 \ | 00015 \| 00016 0 00017 00018 SUKITTI PUNAK (03/11/2006) 00019 UPDATE (03/15/2006) 00020 ******************************************************************************/ 00021 #include "TAPsTriangle.hpp" 00022 // Using Inclusion Model (i.e. definitions are included in declarations) 00023 // (this name.cpp is included in name.hpp) 00024 // Each friend is defined directly inside its declaration. 00025 00026 BEGIN_NAMESPACE_TAPs 00027 //============================================================================= 00028 // Constructors and Destructor 00029 //----------------------------------------------------------------------------- 00030 template <typename T> 00031 Triangle<T>::Triangle ( Vector3<T> V0, Vector3<T> V1, Vector3<T> V2 ) 00032 { 00033 m_vVertex[0] = V0; 00034 m_vVertex[1] = V1; 00035 m_vVertex[2] = V2; 00036 } 00037 //----------------------------------------------------------------------------- 00038 template <typename T> 00039 Triangle<T>::Triangle ( const T[3] V0, const T[3] V1, const T[3] V2 ) 00040 { 00041 m_vVertex[0].SetXYZ( V0[0], V0[1], V0[2] ); 00042 m_vVertex[1].SetXYZ( V1[0], V1[1], V1[2] ); 00043 m_vVertex[2].SetXYZ( V2[0], V2[1], V2[2] ); 00044 } 00045 //----------------------------------------------------------------------------- 00046 template <typename T> 00047 Triangle<T>::Triangle ( T V0x, T V0y, T V0z, 00048 T V1x, T V1y, T V1z, 00049 T V2x, T V2y, T V2z ) 00050 { 00051 m_vVertex[0].SetXYZ( V0x, V0y, V0z ); 00052 m_vVertex[1].SetXYZ( V1x, V1y, V1z ); 00053 m_vVertex[2].SetXYZ( V2x, V2y, V2z ); 00054 } 00055 //----------------------------------------------------------------------------- 00056 template <typename T> 00057 Triangle<T>::Triangle ( const Triangle<T> & tri ) 00058 { 00059 m_vVertex[0] = tri.m_vVertex[0]; 00060 m_vVertex[1] = tri.m_vVertex[1]; 00061 m_vVertex[2] = tri.m_vVertex[2]; 00062 } 00063 //----------------------------------------------------------------------------- 00064 template <typename T> 00065 Triangle<T>::~Triangle () 00066 {} 00067 //----------------------------------------------------------------------------- 00068 //============================================================================= 00069 // Fn(s) for Normal 00070 //----------------------------------------------------------------------------- 00071 template <typename T> 00072 inline Vector3<T> Triangle<T>::CalNormal () const 00073 { 00074 return ( V1-V0 ).Cross( V2-V0 ); 00075 } 00076 //----------------------------------------------------------------------------- 00077 //============================================================================= 00078 // Assignment (Conversion) Operator 00079 //----------------------------------------------------------------------------- 00080 template <typename T> 00081 inline Triangle<T> & Triangle<T>::operator= ( Triangle<T> const & tri ) 00082 { 00083 m_vVertex[0] = tri.m_vVertex[0]; 00084 m_vVertex[1] = tri.m_vVertex[1]; 00085 m_vVertex[2] = tri.m_vVertex[2]; 00086 return *this; 00087 } 00088 //----------------------------------------------------------------------------- 00089 //============================================================================= 00090 END_NAMESPACE_TAPs 00091 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00092 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8