~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Mesh/App/WildMagic4/Wm4Plane3.inl

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Wild Magic Source Code
 
2
// David Eberly
 
3
// http://www.geometrictools.com
 
4
// Copyright (c) 1998-2007
 
5
//
 
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.
 
14
//
 
15
// Version: 4.0.0 (2006/06/28)
 
16
 
 
17
//----------------------------------------------------------------------------
 
18
template <class Real>
 
19
Plane3<Real>::Plane3 ()
 
20
{
 
21
    // uninitialized
 
22
}
 
23
//----------------------------------------------------------------------------
 
24
template <class Real>
 
25
Plane3<Real>::Plane3 (const Plane3& rkPlane)
 
26
    :
 
27
    Normal(rkPlane.Normal)
 
28
{
 
29
    Constant = rkPlane.Constant;
 
30
}
 
31
//----------------------------------------------------------------------------
 
32
template <class Real>
 
33
Plane3<Real>::Plane3 (const Vector3<Real>& rkNormal, Real fConstant)
 
34
    :
 
35
    Normal(rkNormal)
 
36
{
 
37
    Constant = fConstant;
 
38
}
 
39
//----------------------------------------------------------------------------
 
40
template <class Real>
 
41
Plane3<Real>::Plane3 (const Vector3<Real>& rkNormal, const Vector3<Real>& rkP)
 
42
    :
 
43
    Normal(rkNormal)
 
44
{
 
45
    Constant = rkNormal.Dot(rkP);
 
46
}
 
47
//----------------------------------------------------------------------------
 
48
template <class Real>
 
49
Plane3<Real>::Plane3 (const Vector3<Real>& rkP0, const Vector3<Real>& rkP1,
 
50
    const Vector3<Real>& rkP2)
 
51
{
 
52
    Vector3<Real> kEdge1 = rkP1 - rkP0;
 
53
    Vector3<Real> kEdge2 = rkP2 - rkP0;
 
54
    Normal = kEdge1.UnitCross(kEdge2);
 
55
    Constant = Normal.Dot(rkP0);
 
56
}
 
57
//----------------------------------------------------------------------------
 
58
template <class Real>
 
59
Plane3<Real>& Plane3<Real>::operator= (const Plane3& rkPlane)
 
60
{
 
61
    Normal = rkPlane.Normal;
 
62
    Constant = rkPlane.Constant;
 
63
    return *this;
 
64
}
 
65
//----------------------------------------------------------------------------
 
66
template <class Real>
 
67
Real Plane3<Real>::DistanceTo (const Vector3<Real>& rkP) const
 
68
{
 
69
    return Normal.Dot(rkP) - Constant;
 
70
}
 
71
//----------------------------------------------------------------------------
 
72
template <class Real>
 
73
int Plane3<Real>::WhichSide (const Vector3<Real>& rkQ) const
 
74
{
 
75
    Real fDistance = DistanceTo(rkQ);
 
76
 
 
77
    if (fDistance < (Real)0.0)
 
78
    {
 
79
        return -1;
 
80
    }
 
81
 
 
82
    if (fDistance > (Real)0.0)
 
83
    {
 
84
        return +1;
 
85
    }
 
86
 
 
87
    return 0;
 
88
}
 
89
//----------------------------------------------------------------------------