00001 // Wild Magic Source Code 00002 // David Eberly 00003 // http://www.geometrictools.com 00004 // Copyright (c) 1998-2007 00005 // 00006 // This library is free software; you can redistribute it and/or modify it 00007 // under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation; either version 2.1 of the License, or (at 00009 // your option) any later version. The license is available for reading at 00010 // either of the locations: 00011 // http://www.gnu.org/copyleft/lgpl.html 00012 // http://www.geometrictools.com/License/WildMagicLicense.pdf 00013 // The license applies to versions 0 through 4 of Wild Magic. 00014 // 00015 // Version: 4.0.0 (2006/06/28) 00016 00017 namespace Wm4 00018 { 00019 //---------------------------------------------------------------------------- 00020 template <int ISIZE> 00021 RVector2<ISIZE>::RVector2 () 00022 { 00023 // the vector is uninitialized 00024 } 00025 //---------------------------------------------------------------------------- 00026 template <int ISIZE> 00027 RVector2<ISIZE>::RVector2 (const RVector2& rkV) 00028 { 00029 m_akTuple[0] = rkV.m_akTuple[0]; 00030 m_akTuple[1] = rkV.m_akTuple[1]; 00031 } 00032 //---------------------------------------------------------------------------- 00033 #ifndef WM4_USING_VC70 00034 template <int ISIZE> 00035 RVector2<ISIZE>::RVector2 (const TRVector<2,ISIZE>& rkV) 00036 { 00037 m_akTuple[0] = rkV[0]; 00038 m_akTuple[1] = rkV[1]; 00039 } 00040 #endif 00041 //---------------------------------------------------------------------------- 00042 template <int ISIZE> 00043 RVector2<ISIZE>::RVector2 (const TRational<ISIZE>& rkX, 00044 const TRational<ISIZE>& rkY) 00045 { 00046 m_akTuple[0] = rkX; 00047 m_akTuple[1] = rkY; 00048 } 00049 //---------------------------------------------------------------------------- 00050 template <int ISIZE> 00051 RVector2<ISIZE>& RVector2<ISIZE>::operator= (const RVector2& rkV) 00052 { 00053 m_akTuple[0] = rkV.m_akTuple[0]; 00054 m_akTuple[1] = rkV.m_akTuple[1]; 00055 return *this; 00056 } 00057 //---------------------------------------------------------------------------- 00058 #ifndef WM4_USING_VC70 00059 template <int ISIZE> 00060 RVector2<ISIZE>& RVector2<ISIZE>::operator= (const TRVector<2,ISIZE>& rkV) 00061 { 00062 m_akTuple[0] = rkV[0]; 00063 m_akTuple[1] = rkV[1]; 00064 return *this; 00065 } 00066 #endif 00067 //---------------------------------------------------------------------------- 00068 template <int ISIZE> 00069 TRational<ISIZE> RVector2<ISIZE>::X () const 00070 { 00071 return m_akTuple[0]; 00072 } 00073 //---------------------------------------------------------------------------- 00074 template <int ISIZE> 00075 TRational<ISIZE>& RVector2<ISIZE>::X () 00076 { 00077 return m_akTuple[0]; 00078 } 00079 //---------------------------------------------------------------------------- 00080 template <int ISIZE> 00081 TRational<ISIZE> RVector2<ISIZE>::Y () const 00082 { 00083 return m_akTuple[1]; 00084 } 00085 //---------------------------------------------------------------------------- 00086 template <int ISIZE> 00087 TRational<ISIZE>& RVector2<ISIZE>::Y () 00088 { 00089 return m_akTuple[1]; 00090 } 00091 //---------------------------------------------------------------------------- 00092 template <int ISIZE> 00093 TRational<ISIZE> RVector2<ISIZE>::Dot (const RVector2& rkV) const 00094 { 00095 return m_akTuple[0]*rkV.m_akTuple[0] + m_akTuple[1]*rkV.m_akTuple[1]; 00096 } 00097 //---------------------------------------------------------------------------- 00098 template <int ISIZE> 00099 RVector2<ISIZE> RVector2<ISIZE>::Perp () const 00100 { 00101 return RVector2<ISIZE>(m_akTuple[1],-m_akTuple[0]); 00102 } 00103 //---------------------------------------------------------------------------- 00104 template <int ISIZE> 00105 TRational<ISIZE> RVector2<ISIZE>::DotPerp (const RVector2& rkV) const 00106 { 00107 return m_akTuple[0]*rkV.m_akTuple[1] - m_akTuple[1]*rkV.m_akTuple[0]; 00108 } 00109 //---------------------------------------------------------------------------- 00110 } //namespace Wm4