Wm4DistVector3Plane3.cpp

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 #include "Wm4FoundationPCH.h"
00018 #include "Wm4DistVector3Plane3.h"
00019 
00020 namespace Wm4
00021 {
00022 //----------------------------------------------------------------------------
00023 template <class Real>
00024 DistVector3Plane3<Real>::DistVector3Plane3 (const Vector3<Real>& rkVector,
00025     const Plane3<Real>& rkPlane)
00026     :
00027     m_rkVector(rkVector),
00028     m_rkPlane(rkPlane)
00029 {
00030 }
00031 //----------------------------------------------------------------------------
00032 template <class Real>
00033 const Vector3<Real>& DistVector3Plane3<Real>::GetVector () const
00034 {
00035     return m_rkVector;
00036 }
00037 //----------------------------------------------------------------------------
00038 template <class Real>
00039 const Plane3<Real>& DistVector3Plane3<Real>::GetPlane () const
00040 {
00041     return m_rkPlane;
00042 }
00043 //----------------------------------------------------------------------------
00044 template <class Real>
00045 Real DistVector3Plane3<Real>::Get ()
00046 {
00047     Real fSigned = m_rkPlane.Normal.Dot(m_rkVector) - m_rkPlane.Constant;
00048     m_kClosestPoint0 = m_rkVector;
00049     m_kClosestPoint1 = m_rkVector - fSigned*m_rkPlane.Normal;
00050     return Math<Real>::FAbs(fSigned);
00051 }
00052 //----------------------------------------------------------------------------
00053 template <class Real>
00054 Real DistVector3Plane3<Real>::GetSquared ()
00055 {
00056     Real fSigned = m_rkPlane.Normal.Dot(m_rkVector) - m_rkPlane.Constant;
00057     m_kClosestPoint0 = m_rkVector;
00058     m_kClosestPoint1 = m_rkVector - fSigned*m_rkPlane.Normal;
00059     return fSigned*fSigned;
00060 }
00061 //----------------------------------------------------------------------------
00062 template <class Real>
00063 Real DistVector3Plane3<Real>::Get (Real fT, const Vector3<Real>& rkVelocity0,
00064     const Vector3<Real>& rkVelocity1)
00065 {
00066     Vector3<Real> kMVector = m_rkVector + fT*rkVelocity0;
00067     Real fMConstant = m_rkPlane.Constant +
00068         fT*m_rkPlane.Normal.Dot(rkVelocity0);
00069     Plane3<Real> kMPlane(m_rkPlane.Normal,fMConstant);
00070     return DistVector3Plane3<Real>(kMVector,kMPlane).Get();
00071 }
00072 //----------------------------------------------------------------------------
00073 template <class Real>
00074 Real DistVector3Plane3<Real>::GetSquared (Real fT,
00075     const Vector3<Real>& rkVelocity0, const Vector3<Real>& rkVelocity1)
00076 {
00077     Vector3<Real> kMVector = m_rkVector + fT*rkVelocity0;
00078     Real fMConstant = m_rkPlane.Constant +
00079         fT*m_rkPlane.Normal.Dot(rkVelocity0);
00080     Plane3<Real> kMPlane(m_rkPlane.Normal,fMConstant);
00081     return DistVector3Plane3<Real>(kMVector,kMPlane).GetSquared();
00082 }
00083 //----------------------------------------------------------------------------
00084 
00085 //----------------------------------------------------------------------------
00086 // explicit instantiation
00087 //----------------------------------------------------------------------------
00088 template WM4_FOUNDATION_ITEM
00089 class DistVector3Plane3<float>;
00090 
00091 template WM4_FOUNDATION_ITEM
00092 class DistVector3Plane3<double>;
00093 //----------------------------------------------------------------------------
00094 }

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