Wm4RVector3.inl

Go to the documentation of this file.
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 RVector3<ISIZE>::RVector3 ()
00022 {
00023     // the vector is uninitialized
00024 }
00025 //----------------------------------------------------------------------------
00026 template <int ISIZE>
00027 RVector3<ISIZE>::RVector3 (const RVector3& rkV)
00028 {
00029     m_akTuple[0] = rkV.m_akTuple[0];
00030     m_akTuple[1] = rkV.m_akTuple[1];
00031     m_akTuple[2] = rkV.m_akTuple[2];
00032 }
00033 //----------------------------------------------------------------------------
00034 #ifndef WM4_USING_VC70
00035 template <int ISIZE>
00036 RVector3<ISIZE>::RVector3 (const TRVector<3,ISIZE>& rkV)
00037 {
00038     m_akTuple[0] = rkV[0];
00039     m_akTuple[1] = rkV[1];
00040     m_akTuple[2] = rkV[2];
00041 }
00042 #endif
00043 //----------------------------------------------------------------------------
00044 template <int ISIZE>
00045 RVector3<ISIZE>::RVector3 (const TRational<ISIZE>& rkX,
00046     const TRational<ISIZE>& rkY, const TRational<ISIZE>& rkZ)
00047 {
00048     m_akTuple[0] = rkX;
00049     m_akTuple[1] = rkY;
00050     m_akTuple[2] = rkZ;
00051 }
00052 //----------------------------------------------------------------------------
00053 template <int ISIZE>
00054 RVector3<ISIZE>& RVector3<ISIZE>::operator= (const RVector3& rkV)
00055 {
00056     m_akTuple[0] = rkV.m_akTuple[0];
00057     m_akTuple[1] = rkV.m_akTuple[1];
00058     m_akTuple[2] = rkV.m_akTuple[2];
00059     return *this;
00060 }
00061 //----------------------------------------------------------------------------
00062 #ifndef WM4_USING_VC70
00063 template <int ISIZE>
00064 RVector3<ISIZE>& RVector3<ISIZE>::operator= (const TRVector<3,ISIZE>& rkV)
00065 {
00066     m_akTuple[0] = rkV[0];
00067     m_akTuple[1] = rkV[1];
00068     m_akTuple[2] = rkV[2];
00069     return *this;
00070 }
00071 #endif
00072 //----------------------------------------------------------------------------
00073 template <int ISIZE>
00074 TRational<ISIZE> RVector3<ISIZE>::X () const
00075 {
00076     return m_akTuple[0];
00077 }
00078 //----------------------------------------------------------------------------
00079 template <int ISIZE>
00080 TRational<ISIZE>& RVector3<ISIZE>::X ()
00081 {
00082     return m_akTuple[0];
00083 }
00084 //----------------------------------------------------------------------------
00085 template <int ISIZE>
00086 TRational<ISIZE> RVector3<ISIZE>::Y () const
00087 {
00088     return m_akTuple[1];
00089 }
00090 //----------------------------------------------------------------------------
00091 template <int ISIZE>
00092 TRational<ISIZE>& RVector3<ISIZE>::Y ()
00093 {
00094     return m_akTuple[1];
00095 }
00096 //----------------------------------------------------------------------------
00097 template <int ISIZE>
00098 TRational<ISIZE> RVector3<ISIZE>::Z () const
00099 {
00100     return m_akTuple[2];
00101 }
00102 //----------------------------------------------------------------------------
00103 template <int ISIZE>
00104 TRational<ISIZE>& RVector3<ISIZE>::Z ()
00105 {
00106     return m_akTuple[2];
00107 }
00108 //----------------------------------------------------------------------------
00109 template <int ISIZE>
00110 TRational<ISIZE> RVector3<ISIZE>::Dot (const RVector3& rkV) const
00111 {
00112     return m_akTuple[0]*rkV.m_akTuple[0] + m_akTuple[1]*rkV.m_akTuple[1] +
00113         m_akTuple[2]*rkV.m_akTuple[2];
00114 }
00115 //----------------------------------------------------------------------------
00116 template <int ISIZE>
00117 RVector3<ISIZE> RVector3<ISIZE>::Cross (const RVector3& rkV) const
00118 {
00119     return RVector3<ISIZE>(
00120         m_akTuple[1]*rkV.m_akTuple[2] - m_akTuple[2]*rkV.m_akTuple[1],
00121         m_akTuple[2]*rkV.m_akTuple[0] - m_akTuple[0]*rkV.m_akTuple[2],
00122         m_akTuple[0]*rkV.m_akTuple[1] - m_akTuple[1]*rkV.m_akTuple[0]);
00123 }
00124 //----------------------------------------------------------------------------
00125 template <int ISIZE>
00126 TRational<ISIZE> RVector3<ISIZE>::TripleScalar (const RVector3& rkU,
00127     const RVector3& rkV) const
00128 {
00129     return Dot(rkU.Cross(rkV));
00130 }
00131 //----------------------------------------------------------------------------
00132 } //namespace Wm4

Generated on Wed Nov 23 19:01:08 2011 for FreeCAD by  doxygen 1.6.1