Ocular Engine
Plane.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_MATH_PLANE__H__
19 #define __H__OCULAR_MATH_PLANE__H__
20 
21 #include "Math/Vector3.hpp"
22 #include "Exceptions/Exception.hpp"
23 
24 #include <array>
25 
26 //------------------------------------------------------------------------------------------
27 
32 namespace Ocular
33 {
38  namespace Math
39  {
40  class Ray;
41  class BoundsSphere;
42  class BoundsAABB;
43  class BoundsOBB;
44 
50  class Plane
51  {
52  public:
53 
60  Plane(Vector3f const& point, Vector3f const& normal);
61 
75  Plane(Point3f const& a, Point3f const& b, Point3f const& c);
76 
77  Plane();
78  ~Plane();
79 
83  void setPoint(Vector3f const& point);
84 
88  void setNormal(Vector3f const& normal);
89 
93  Vector3f const& getPoint() const;
94 
98  Vector3f const& getNormal() const;
99 
110  float getSignedDistance(Vector3f const& point) const;
111 
118  Vector3f getClosest(Vector3f const& point) const;
119 
120  void normalize();
121 
122  Plane getNormalized() const;
123 
124  //------------------------------------------------------------------------------
125  // Intersection and Containment Testing
126  //------------------------------------------------------------------------------
127 
137  bool intersects(Ray const& ray) const;
138 
151  bool intersects(Ray const& ray, Vector3f& point, float& distance) const;
152 
176  bool intersects(BoundsSphere const& bounds, IntersectionType* result = nullptr) const;
177 
201  bool intersects(BoundsAABB const& bounds, IntersectionType* result = nullptr) const;
202 
227  bool intersects(BoundsOBB const& bounds, IntersectionType* result = nullptr) const;
228 
229  //------------------------------------------------------------------------------
230  // Static Methods
231  //------------------------------------------------------------------------------
232 
240  static Vector3f GetIntersectionPoint(Plane const& a, Plane const& b, Plane const& c);
241 
242  protected:
243 
244  private:
245 
246  Vector3f m_Point;
247  Vector3f m_Normal;
248  };
249  }
253 }
258 //------------------------------------------------------------------------------------------
259 
260 #endif
static Vector3f GetIntersectionPoint(Plane const &a, Plane const &b, Plane const &c)
Definition: Plane.cpp:142
Definition: Ray.hpp:47
void setPoint(Vector3f const &point)
Definition: Plane.cpp:65
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: BoundsOBB.hpp:56
Vector3f getClosest(Vector3f const &point) const
Definition: Plane.cpp:90
Definition: Plane.hpp:50
bool intersects(Ray const &ray) const
Definition: Plane.cpp:117
Vector3f const & getNormal() const
Definition: Plane.cpp:80
void setNormal(Vector3f const &normal)
Definition: Plane.cpp:70
Definition: BoundsAABB.hpp:63
Definition: BoundsSphere.hpp:52
Vector3f const & getPoint() const
Definition: Plane.cpp:75
float getSignedDistance(Vector3f const &point) const
Definition: Plane.cpp:85