OgrePlane.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 // This file is based on material originally from:
29 // Geometric Tools, LLC
30 // Copyright (c) 1998-2010
31 // Distributed under the Boost Software License, Version 1.0.
32 // http://www.boost.org/LICENSE_1_0.txt
33 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
34 
35 
36 #ifndef __Plane_H__
37 #define __Plane_H__
38 
39 #include "OgrePrerequisites.h"
40 
41 #include "OgreVector3.h"
42 
43 namespace Ogre {
44 
62  {
63  public:
66  Plane ();
67  Plane (const Plane& rhs);
69  Plane (const Vector3& rkNormal, Real fConstant);
71  Plane (Real a, Real b, Real c, Real d);
72  Plane (const Vector3& rkNormal, const Vector3& rkPoint);
73  Plane (const Vector3& rkPoint0, const Vector3& rkPoint1,
74  const Vector3& rkPoint2);
75 
80  enum Side
81  {
85  BOTH_SIDE
86  };
87 
88  Side getSide (const Vector3& rkPoint) const;
89 
94  Side getSide (const AxisAlignedBox& rkBox) const;
95 
105  Side getSide (const Vector3& centre, const Vector3& halfSize) const;
106 
115  Real getDistance (const Vector3& rkPoint) const;
116 
118  void redefine(const Vector3& rkPoint0, const Vector3& rkPoint1,
119  const Vector3& rkPoint2);
120 
122  void redefine(const Vector3& rkNormal, const Vector3& rkPoint);
123 
131  Vector3 projectVector(const Vector3& v) const;
132 
143 
146 
148  bool operator==(const Plane& rhs) const
149  {
150  return (rhs.d == d && rhs.normal == normal);
151  }
152  bool operator!=(const Plane& rhs) const
153  {
154  return (rhs.d != d || rhs.normal != normal);
155  }
156 
157  _OgreExport friend std::ostream& operator<< (std::ostream& o, const Plane& p);
158  };
159 
164 } // namespace Ogre
165 
166 #endif
#define _OgreExport
Definition: OgrePlatform.h:257
A 3D box aligned with the x/y/z axes.
Defines a plane in 3D space.
Definition: OgrePlane.h:62
Real normalise(void)
Normalises the plane.
Side getSide(const AxisAlignedBox &rkBox) const
Returns the side where the alignedBox is.
Plane()
Default constructor - sets everything to 0.
Plane(const Plane &rhs)
Side getSide(const Vector3 &centre, const Vector3 &halfSize) const
Returns which side of the plane that the given box lies on.
bool operator==(const Plane &rhs) const
Comparison operator.
Definition: OgrePlane.h:148
Plane(const Vector3 &rkNormal, Real fConstant)
Construct a plane through a normal, and a distance to move the plane along the normal.
void redefine(const Vector3 &rkPoint0, const Vector3 &rkPoint1, const Vector3 &rkPoint2)
Redefine this plane based on 3 points.
Vector3 normal
Definition: OgrePlane.h:144
Vector3 projectVector(const Vector3 &v) const
Project a vector onto the plane.
Side getSide(const Vector3 &rkPoint) const
bool operator!=(const Plane &rhs) const
Definition: OgrePlane.h:152
Plane(Real a, Real b, Real c, Real d)
Construct a plane using the 4 constants directly.
void redefine(const Vector3 &rkNormal, const Vector3 &rkPoint)
Redefine this plane based on a normal and a point.
Real getDistance(const Vector3 &rkPoint) const
This is a pseudodistance.
Side
The "positive side" of the plane is the half space to which the plane normal points.
Definition: OgrePlane.h:81
@ NEGATIVE_SIDE
Definition: OgrePlane.h:84
@ POSITIVE_SIDE
Definition: OgrePlane.h:83
Plane(const Vector3 &rkNormal, const Vector3 &rkPoint)
Plane(const Vector3 &rkPoint0, const Vector3 &rkPoint1, const Vector3 &rkPoint2)
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
std::ostream & operator<<(std::ostream &o, const TRect< T > &r)
Definition: OgreCommon.h:636
vector< Plane >::type PlaneList
Definition: OgrePlane.h:160
float Real
Software floating point type.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.