aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/OPCODE/Ice/IcePlane.h
diff options
context:
space:
mode:
authordan miller2007-10-21 08:36:32 +0000
committerdan miller2007-10-21 08:36:32 +0000
commit2f8d7092bc2c9609fa98d6888106b96f38b22828 (patch)
treeda6c37579258cc965b52a75aee6135fe44237698 /libraries/ode-0.9/OPCODE/Ice/IcePlane.h
parent* Committing new PolicyManager based on an ACL system. (diff)
downloadopensim-SC_OLD-2f8d7092bc2c9609fa98d6888106b96f38b22828.zip
opensim-SC_OLD-2f8d7092bc2c9609fa98d6888106b96f38b22828.tar.gz
opensim-SC_OLD-2f8d7092bc2c9609fa98d6888106b96f38b22828.tar.bz2
opensim-SC_OLD-2f8d7092bc2c9609fa98d6888106b96f38b22828.tar.xz
libraries moved to opensim-libs, a new repository
Diffstat (limited to 'libraries/ode-0.9/OPCODE/Ice/IcePlane.h')
-rw-r--r--libraries/ode-0.9/OPCODE/Ice/IcePlane.h113
1 files changed, 0 insertions, 113 deletions
diff --git a/libraries/ode-0.9/OPCODE/Ice/IcePlane.h b/libraries/ode-0.9/OPCODE/Ice/IcePlane.h
deleted file mode 100644
index 4d47081..0000000
--- a/libraries/ode-0.9/OPCODE/Ice/IcePlane.h
+++ /dev/null
@@ -1,113 +0,0 @@
1///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2/**
3 * Contains code for planes.
4 * \file IcePlane.h
5 * \author Pierre Terdiman
6 * \date April, 4, 2000
7 */
8///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9
10///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11// Include Guard
12#ifndef __ICEPLANE_H__
13#define __ICEPLANE_H__
14
15 #define PLANE_EPSILON (1.0e-7f)
16
17 class ICEMATHS_API Plane
18 {
19 public:
20 //! Constructor
21 inline_ Plane() { }
22 //! Constructor from a normal and a distance
23 inline_ Plane(float nx, float ny, float nz, float d) { Set(nx, ny, nz, d); }
24 //! Constructor from a point on the plane and a normal
25 inline_ Plane(const Point& p, const Point& n) { Set(p, n); }
26 //! Constructor from three points
27 inline_ Plane(const Point& p0, const Point& p1, const Point& p2) { Set(p0, p1, p2); }
28 //! Constructor from a normal and a distance
29 inline_ Plane(const Point& _n, float _d) { n = _n; d = _d; }
30 //! Copy constructor
31 inline_ Plane(const Plane& plane) : n(plane.n), d(plane.d) { }
32 //! Destructor
33 inline_ ~Plane() { }
34
35 inline_ Plane& Zero() { n.Zero(); d = 0.0f; return *this; }
36 inline_ Plane& Set(float nx, float ny, float nz, float _d) { n.Set(nx, ny, nz); d = _d; return *this; }
37 inline_ Plane& Set(const Point& p, const Point& _n) { n = _n; d = - p | _n; return *this; }
38 Plane& Set(const Point& p0, const Point& p1, const Point& p2);
39
40 inline_ float Distance(const Point& p) const { return (p | n) + d; }
41 inline_ bool Belongs(const Point& p) const { return fabsf(Distance(p)) < PLANE_EPSILON; }
42
43 inline_ void Normalize()
44 {
45 float Denom = 1.0f / n.Magnitude();
46 n.x *= Denom;
47 n.y *= Denom;
48 n.z *= Denom;
49 d *= Denom;
50 }
51 public:
52 // Members
53 Point n; //!< The normal to the plane
54 float d; //!< The distance from the origin
55
56 // Cast operators
57 inline_ operator Point() const { return n; }
58 inline_ operator HPoint() const { return HPoint(n, d); }
59
60 // Arithmetic operators
61 inline_ Plane operator*(const Matrix4x4& m) const
62 {
63 // Old code from Irion. Kept for reference.
64 Plane Ret(*this);
65 return Ret *= m;
66 }
67
68 inline_ Plane& operator*=(const Matrix4x4& m)
69 {
70 // Old code from Irion. Kept for reference.
71 Point n2 = HPoint(n, 0.0f) * m;
72 d = -((Point) (HPoint( -d*n, 1.0f ) * m) | n2);
73 n = n2;
74 return *this;
75 }
76 };
77
78 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
79 /**
80 * Transforms a plane by a 4x4 matrix. Same as Plane * Matrix4x4 operator, but faster.
81 * \param transformed [out] transformed plane
82 * \param plane [in] source plane
83 * \param transform [in] transform matrix
84 * \warning the plane normal must be unit-length
85 */
86 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
87 inline_ void TransformPlane(Plane& transformed, const Plane& plane, const Matrix4x4& transform)
88 {
89 // Rotate the normal using the rotation part of the 4x4 matrix
90 transformed.n = plane.n * Matrix3x3(transform);
91
92 // Compute new d
93 transformed.d = plane.d - (Point(transform.GetTrans())|transformed.n);
94 }
95
96 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
97 /**
98 * Transforms a plane by a 4x4 matrix. Same as Plane * Matrix4x4 operator, but faster.
99 * \param plane [in/out] source plane (transformed on return)
100 * \param transform [in] transform matrix
101 * \warning the plane normal must be unit-length
102 */
103 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
104 inline_ void TransformPlane(Plane& plane, const Matrix4x4& transform)
105 {
106 // Rotate the normal using the rotation part of the 4x4 matrix
107 plane.n *= Matrix3x3(transform);
108
109 // Compute new d
110 plane.d -= Point(transform.GetTrans())|plane.n;
111 }
112
113#endif // __ICEPLANE_H__