Wm4Plane3.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 <class Real>
00021 Plane3<Real>::Plane3 ()
00022 {
00023     // uninitialized
00024 }
00025 //----------------------------------------------------------------------------
00026 template <class Real>
00027 Plane3<Real>::Plane3 (const Plane3& rkPlane)
00028     :
00029     Normal(rkPlane.Normal)
00030 {
00031     Constant = rkPlane.Constant;
00032 }
00033 //----------------------------------------------------------------------------
00034 template <class Real>
00035 Plane3<Real>::Plane3 (const Vector3<Real>& rkNormal, Real fConstant)
00036     :
00037     Normal(rkNormal)
00038 {
00039     Constant = fConstant;
00040 }
00041 //----------------------------------------------------------------------------
00042 template <class Real>
00043 Plane3<Real>::Plane3 (const Vector3<Real>& rkNormal, const Vector3<Real>& rkP)
00044     :
00045     Normal(rkNormal)
00046 {
00047     Constant = rkNormal.Dot(rkP);
00048 }
00049 //----------------------------------------------------------------------------
00050 template <class Real>
00051 Plane3<Real>::Plane3 (const Vector3<Real>& rkP0, const Vector3<Real>& rkP1,
00052     const Vector3<Real>& rkP2)
00053 {
00054     Vector3<Real> kEdge1 = rkP1 - rkP0;
00055     Vector3<Real> kEdge2 = rkP2 - rkP0;
00056     Normal = kEdge1.UnitCross(kEdge2);
00057     Constant = Normal.Dot(rkP0);
00058 }
00059 //----------------------------------------------------------------------------
00060 template <class Real>
00061 Plane3<Real>& Plane3<Real>::operator= (const Plane3& rkPlane)
00062 {
00063     Normal = rkPlane.Normal;
00064     Constant = rkPlane.Constant;
00065     return *this;
00066 }
00067 //----------------------------------------------------------------------------
00068 template <class Real>
00069 Real Plane3<Real>::DistanceTo (const Vector3<Real>& rkP) const
00070 {
00071     return Normal.Dot(rkP) - Constant;
00072 }
00073 //----------------------------------------------------------------------------
00074 template <class Real>
00075 int Plane3<Real>::WhichSide (const Vector3<Real>& rkQ) const
00076 {
00077     Real fDistance = DistanceTo(rkQ);
00078 
00079     if (fDistance < (Real)0.0)
00080     {
00081         return -1;
00082     }
00083 
00084     if (fDistance > (Real)0.0)
00085     {
00086         return +1;
00087     }
00088 
00089     return 0;
00090 }
00091 //----------------------------------------------------------------------------
00092 } //namespace Wm4
00093 

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