Wm4Plane3.h

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 #ifndef WM4PLANE3_H
00018 #define WM4PLANE3_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Vector3.h"
00022 
00023 namespace Wm4
00024 {
00025 
00026 template <class Real>
00027 class Plane3
00028 {
00029 public:
00030     // The plane is represented as Dot(N,X) = c where N is a unit-length
00031     // normal vector, c is the plane constant, and X is any point on the
00032     // plane.  The user must ensure that the normal vector satisfies this
00033     // condition.
00034 
00035     Plane3 ();  // uninitialized
00036     Plane3 (const Plane3& rkPlane);
00037 
00038     // specify N and c directly
00039     Plane3 (const Vector3<Real>& rkNormal, Real fConstant);
00040 
00041     // N is specified, c = Dot(N,P) where P is on the plane
00042     Plane3 (const Vector3<Real>& rkNormal, const Vector3<Real>& rkP);
00043 
00044     // N = Cross(P1-P0,P2-P0)/Length(Cross(P1-P0,P2-P0)), c = Dot(N,P0) where
00045     // P0, P1, P2 are points on the plane.
00046     Plane3 (const Vector3<Real>& rkP0, const Vector3<Real>& rkP1,
00047         const Vector3<Real>& rkP2);
00048 
00049     // assignment
00050     Plane3& operator= (const Plane3& rkPlane);
00051 
00052     // The "positive side" of the plane is the half space to which the plane
00053     // normal points.  The "negative side" is the other half space.  The
00054     // function returns +1 for the positive side, -1 for the negative side,
00055     // and 0 for the point being on the plane.
00056     int WhichSide (const Vector3<Real>& rkP) const;
00057 
00058     // Compute d = Dot(N,Q)-c where N is the plane normal and c is the plane
00059     // constant.  This is a signed distance.  The sign of the return value is
00060     // positive if the point is on the positive side of the plane, negative if
00061     // the point is on the negative side, and zero if the point is on the
00062     // plane.
00063     Real DistanceTo (const Vector3<Real>& rkQ) const;
00064 
00065     Vector3<Real> Normal;
00066     Real Constant;
00067 };
00068 
00069 } //namespace Wm4
00070 
00071 #include "Wm4Plane3.inl"
00072 
00073 namespace Wm4
00074 {
00075 typedef Plane3<float> Plane3f;
00076 typedef Plane3<double> Plane3d;
00077 }
00078 
00079 #endif

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