Wm4DistVector3Plane3.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00087
00088 template WM4_FOUNDATION_ITEM
00089 class DistVector3Plane3<float>;
00090
00091 template WM4_FOUNDATION_ITEM
00092 class DistVector3Plane3<double>;
00093
00094 }