Wm4Box3.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 Box3<Real>::Box3 ()
00022 {
00023     // uninitialized
00024 }
00025 //----------------------------------------------------------------------------
00026 template <class Real>
00027 Box3<Real>::Box3 (const Vector3<Real>& rkCenter, const Vector3<Real>* akAxis,
00028     const Real* afExtent)
00029     :
00030     Center(rkCenter)
00031 {
00032     for (int i = 0; i < 3; i++)
00033     {
00034         Axis[i] = akAxis[i];
00035         Extent[i] = afExtent[i];
00036     }
00037 }
00038 //----------------------------------------------------------------------------
00039 template <class Real>
00040 Box3<Real>::Box3 (const Vector3<Real>& rkCenter, const Vector3<Real>& rkAxis0,
00041     const Vector3<Real>& rkAxis1, const Vector3<Real>& rkAxis2, Real fExtent0,
00042     Real fExtent1, Real fExtent2)
00043     :
00044     Center(rkCenter)
00045 {
00046     Axis[0] = rkAxis0;
00047     Axis[1] = rkAxis1;
00048     Axis[2] = rkAxis2;
00049     Extent[0] = fExtent0;
00050     Extent[1] = fExtent1;
00051     Extent[2] = fExtent2;
00052 }
00053 //----------------------------------------------------------------------------
00054 template <class Real>
00055 void Box3<Real>::ComputeVertices (Vector3<Real> akVertex[8]) const
00056 {
00057     Vector3<Real> akEAxis[3] =
00058     {
00059         Extent[0]*Axis[0],
00060         Extent[1]*Axis[1],
00061         Extent[2]*Axis[2]
00062     };
00063 
00064     akVertex[0] = Center - akEAxis[0] - akEAxis[1] - akEAxis[2];
00065     akVertex[1] = Center + akEAxis[0] - akEAxis[1] - akEAxis[2];
00066     akVertex[2] = Center + akEAxis[0] + akEAxis[1] - akEAxis[2];
00067     akVertex[3] = Center - akEAxis[0] + akEAxis[1] - akEAxis[2];
00068     akVertex[4] = Center - akEAxis[0] - akEAxis[1] + akEAxis[2];
00069     akVertex[5] = Center + akEAxis[0] - akEAxis[1] + akEAxis[2];
00070     akVertex[6] = Center + akEAxis[0] + akEAxis[1] + akEAxis[2];
00071     akVertex[7] = Center - akEAxis[0] + akEAxis[1] + akEAxis[2];
00072 }
00073 //----------------------------------------------------------------------------
00074 } //namespace Wm4

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