1
// Wild Magic Source Code
3
// http://www.geometrictools.com
4
// Copyright (c) 1998-2007
6
// This library is free software; you can redistribute it and/or modify it
7
// under the terms of the GNU Lesser General Public License as published by
8
// the Free Software Foundation; either version 2.1 of the License, or (at
9
// your option) any later version. The license is available for reading at
10
// either of the locations:
11
// http://www.gnu.org/copyleft/lgpl.html
12
// http://www.geometrictools.com/License/WildMagicLicense.pdf
13
// The license applies to versions 0 through 4 of Wild Magic.
15
// Version: 4.0.0 (2006/06/28)
17
//----------------------------------------------------------------------------
19
Plane3<Real>::Plane3 ()
23
//----------------------------------------------------------------------------
25
Plane3<Real>::Plane3 (const Plane3& rkPlane)
27
Normal(rkPlane.Normal)
29
Constant = rkPlane.Constant;
31
//----------------------------------------------------------------------------
33
Plane3<Real>::Plane3 (const Vector3<Real>& rkNormal, Real fConstant)
39
//----------------------------------------------------------------------------
41
Plane3<Real>::Plane3 (const Vector3<Real>& rkNormal, const Vector3<Real>& rkP)
45
Constant = rkNormal.Dot(rkP);
47
//----------------------------------------------------------------------------
49
Plane3<Real>::Plane3 (const Vector3<Real>& rkP0, const Vector3<Real>& rkP1,
50
const Vector3<Real>& rkP2)
52
Vector3<Real> kEdge1 = rkP1 - rkP0;
53
Vector3<Real> kEdge2 = rkP2 - rkP0;
54
Normal = kEdge1.UnitCross(kEdge2);
55
Constant = Normal.Dot(rkP0);
57
//----------------------------------------------------------------------------
59
Plane3<Real>& Plane3<Real>::operator= (const Plane3& rkPlane)
61
Normal = rkPlane.Normal;
62
Constant = rkPlane.Constant;
65
//----------------------------------------------------------------------------
67
Real Plane3<Real>::DistanceTo (const Vector3<Real>& rkP) const
69
return Normal.Dot(rkP) - Constant;
71
//----------------------------------------------------------------------------
73
int Plane3<Real>::WhichSide (const Vector3<Real>& rkQ) const
75
Real fDistance = DistanceTo(rkQ);
77
if (fDistance < (Real)0.0)
82
if (fDistance > (Real)0.0)
89
//----------------------------------------------------------------------------