Wm4RVector2.h

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 #ifndef WM4RVECTOR2_H
00018 #define WM4RVECTOR2_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4TRVector.h"
00022 
00023 namespace Wm4
00024 {
00025 
00026 template <int ISIZE>
00027 class RVector2 : public TRVector<2,ISIZE>
00028 {
00029 public:
00030     // construction
00031     RVector2 ();
00032     RVector2 (const RVector2& rkV);
00033 
00034 #ifdef WM4_USING_VC70
00035     RVector2 (const TRVector<2,ISIZE>& rkV)
00036     {
00037         // The inline body is here because of an apparent MSVC++ .NET 2002
00038         // compiler bug.  If placed in the *.inl file, the compiler complains:
00039         //
00040         //   error C2244: 'Wm4::RVector2<>::__ctor' : unable to match function
00041         //       definition to an existing declaration
00042         //   definition
00043         //       'Wm4::RVector2<>::RVector2(const Wm4::TRVector<2,> &)'
00044         //   existing declarations
00045         //       'Wm4::RVector2<>::RVector2(const Wm4::TRational<> &,
00046         //                                  const Wm4::TRational<> &)'
00047         //       'Wm4::RVector2<>::RVector2(const Wm4::TRVector<2,> &)'
00048         //       'Wm4::RVector2<>::RVector2(const Wm4::RVector2<> &)'
00049         //       'Wm4::RVector2<>::RVector2(void)'
00050         // The "definition" is in the "existing declarations" list, so I do
00051         // not know what the compiler is complaining about.
00052 
00053         m_akTuple[0] = rkV[0];
00054         m_akTuple[1] = rkV[1];
00055     }
00056 #else
00057     RVector2 (const TRVector<2,ISIZE>& rkV);
00058 #endif
00059 
00060     RVector2 (const TRational<ISIZE>& rkX, const TRational<ISIZE>& rkY);
00061 
00062     // member access
00063     TRational<ISIZE> X () const;
00064     TRational<ISIZE>& X ();
00065     TRational<ISIZE> Y () const;
00066     TRational<ISIZE>& Y ();
00067 
00068     // assignment
00069     RVector2& operator= (const RVector2& rkV);
00070 
00071 #ifdef WM4_USING_VC70
00072     RVector2& operator= (const TRVector<2,ISIZE>& rkV)
00073     {
00074         // The inline body is here because of an apparent MSVC++ .NET 2002
00075         // compiler bug.  If placed in the *.inl file, the compiler complains:
00076         //
00077         //   error C2244: 'Wm4::RVector2<>::operator`='' : unable to match
00078         //       function definition to an existing declaration
00079         //   definition
00080         //       'Wm4::RVector2<> &Wm4::RVector2<>::operator =(
00081         //            const Wm4::TRVector<2,> &)'
00082         //   existing declarations
00083         //       'Wm4::RVector2<> &Wm4::RVector2<>::operator =(
00084         //            const Wm4::TRVector<2,> &)'
00085         //       'Wm4::RVector2<> &Wm4::RVector2<>::operator =(
00086         //            const Wm4::RVector2<> &)'
00087 
00088         m_akTuple[0] = rkV[0];
00089         m_akTuple[1] = rkV[1];
00090         return *this;
00091     }
00092 #else
00093     RVector2& operator= (const TRVector<2,ISIZE>& rkV);
00094 #endif
00095 
00096     // returns Dot(this,V)
00097     TRational<ISIZE> Dot (const RVector2& rkV) const;
00098 
00099     // returns (y,-x)
00100     RVector2 Perp () const;
00101 
00102     // returns Cross((x,y,0),(V.x,V.y,0)) = x*V.y - y*V.x
00103     TRational<ISIZE> DotPerp (const RVector2& rkV) const;
00104 
00105 protected:
00106     using TRVector<2,ISIZE>::m_akTuple;
00107 };
00108 
00109 }
00110 
00111 #include "Wm4RVector2.inl"
00112 
00113 
00114 #endif

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