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 WM4DISTSEGMENT3TRIANGLE3_H 00018 #define WM4DISTSEGMENT3TRIANGLE3_H 00019 00020 #include "Wm4FoundationLIB.h" 00021 #include "Wm4Distance.h" 00022 #include "Wm4Segment3.h" 00023 #include "Wm4Triangle3.h" 00024 00025 namespace Wm4 00026 { 00027 00028 template <class Real> 00029 class WM4_FOUNDATION_ITEM DistSegment3Triangle3 00030 : public Distance<Real,Vector3<Real> > 00031 { 00032 public: 00033 DistSegment3Triangle3 (const Segment3<Real>& rkSegment, 00034 const Triangle3<Real>& rkTriangle); 00035 00036 // object access 00037 const Segment3<Real>& GetSegment () const; 00038 const Triangle3<Real>& GetTriangle () const; 00039 00040 // static distance queries 00041 virtual Real Get (); 00042 virtual Real GetSquared (); 00043 00044 // function calculations for dynamic distance queries 00045 virtual Real Get (Real fT, const Vector3<Real>& rkVelocity0, 00046 const Vector3<Real>& rkVelocity1); 00047 virtual Real GetSquared (Real fT, const Vector3<Real>& rkVelocity0, 00048 const Vector3<Real>& rkVelocity1); 00049 00050 // Information about the closest points. 00051 Real GetSegmentParameter () const; 00052 Real GetTriangleBary (int i) const; 00053 00054 private: 00055 using Distance<Real,Vector3<Real> >::m_kClosestPoint0; 00056 using Distance<Real,Vector3<Real> >::m_kClosestPoint1; 00057 00058 const Segment3<Real>& m_rkSegment; 00059 const Triangle3<Real>& m_rkTriangle; 00060 00061 // Information about the closest points. 00062 Real m_fSegmentParameter; // closest0 = seg.origin+param*seg.direction 00063 Real m_afTriangleBary[3]; // closest1 = sum_{i=0}^2 bary[i]*tri.vertex[i] 00064 }; 00065 00066 typedef DistSegment3Triangle3<float> DistSegment3Triangle3f; 00067 typedef DistSegment3Triangle3<double> DistSegment3Triangle3d; 00068 00069 } 00070 00071 #endif