SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLPlane.h
Go to the documentation of this file.
1 /**
2  * \file math/SLPlane.h
3  * \brief Declaration of a 3D plane class
4  * \date July 2014
5  * \authors Marcus Hudritsch
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifndef SLPLANE_H
12 #define SLPLANE_H
13 
14 #include <SLMath.h>
15 #include <SLVec3.h>
16 
17 //-----------------------------------------------------------------------------
18 //! Defines a plane in 3D space with the equation ax + by + cy + d = 0
19 /*!
20 SLPlane defines a plane in 3D space with the equation ax + by + cy + d = 0
21 where [a,b,c] is the plane normal and d is the distance from [0,0,0]. The class
22 is used to define the 6 planes of the view frustum.
23 */
24 class SLPlane
25 {
26 public:
27  SLPlane(const SLVec3f& v1,
28  const SLVec3f& v2,
29  const SLVec3f& v3);
31  {
32  N.set(0, 0, 1);
33  d = 0.0f;
34  }
35  ~SLPlane() { ; }
36 
37  SLVec3f N; //!< plane normal
38  SLfloat d; //!< d = -(ax+by+cy) = -normal.dot(point)
39 
40  void setPoints(const SLVec3f& v1,
41  const SLVec3f& v2,
42  const SLVec3f& v3);
43  void setNormalAndPoint(const SLVec3f& N,
44  const SLVec3f& P);
45  void setCoefficients(const SLfloat A,
46  const SLfloat B,
47  const SLfloat C,
48  const SLfloat D);
49 
50  //! Returns distance between a point P and the plane
51  inline SLfloat distToPoint(const SLVec3f& p) { return (d + N.dot(p)); }
52 
53  void print(const char* name);
54 };
55 //-----------------------------------------------------------------------------
56 #endif
float SLfloat
Definition: SL.h:173
Defines a plane in 3D space with the equation ax + by + cy + d = 0.
Definition: SLPlane.h:25
void setCoefficients(const SLfloat A, const SLfloat B, const SLfloat C, const SLfloat D)
Definition: SLPlane.cpp:50
SLfloat distToPoint(const SLVec3f &p)
Returns distance between a point P and the plane.
Definition: SLPlane.h:51
SLfloat d
d = -(ax+by+cy) = -normal.dot(point)
Definition: SLPlane.h:38
SLPlane()
Definition: SLPlane.h:30
void setPoints(const SLVec3f &v1, const SLVec3f &v2, const SLVec3f &v3)
Definition: SLPlane.cpp:26
~SLPlane()
Definition: SLPlane.h:35
void print(const char *name)
Definition: SLPlane.cpp:71
SLVec3f N
plane normal
Definition: SLPlane.h:37
void setNormalAndPoint(const SLVec3f &N, const SLVec3f &P)
Definition: SLPlane.cpp:40
void set(const T X, const T Y, const T Z)
Definition: SLVec3.h:59
T dot(const SLVec3 &v) const
Definition: SLVec3.h:117
V3 v3(float x, float y, float z)
Definition: WAIMath.h:38