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 WM4SEGMENT3_H 00018 #define WM4SEGMENT3_H 00019 00020 #include "Wm4FoundationLIB.h" 00021 #include "Wm4Vector3.h" 00022 00023 namespace Wm4 00024 { 00025 00026 template <class Real> 00027 class Segment3 00028 { 00029 public: 00030 // The segment is represented as P+t*D, where P is the segment origin, 00031 // D is a unit-length direction vector and |t| <= e. The value e is 00032 // referred to as the extent of the segment. The end points of the 00033 // segment are P-e*D and P+e*D. The user must ensure that the direction 00034 // vector is unit-length. The representation for a segment is analogous 00035 // to that for an oriented bounding box. P is the center, D is the 00036 // axis direction, and e is the extent. 00037 00038 // construction 00039 Segment3 (); // uninitialized 00040 Segment3 (const Vector3<Real>& rkOrigin, const Vector3<Real>& rkDirection, 00041 Real fExtent); 00042 00043 // end points 00044 Vector3<Real> GetPosEnd () const; // P+e*D 00045 Vector3<Real> GetNegEnd () const; // P-e*D 00046 00047 Vector3<Real> Origin, Direction; 00048 Real Extent; 00049 }; 00050 00051 } 00052 00053 #include "Wm4Segment3.inl" 00054 00055 namespace Wm4 00056 { 00057 typedef Segment3<float> Segment3f; 00058 typedef Segment3<double> Segment3d; 00059 00060 } 00061 00062 #endif