TDME2  1.9.200
Plane.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tdme/tdme.h>
5 #include <tdme/math/fwd-tdme.h>
6 #include <tdme/math/Vector3.h>
7 
9 
10 /**
11  * Plane entity, this is not directly connectable with physics engine
12  * @author Andreas Drewke
13  */
15 {
16 private:
18  float distance;
19 
20 public:
21  /**
22  * Public constructor
23  */
24  inline Plane() {
25  normal.set(0.0f, 0.0f, 0.0f);
26  distance = 0.0f;
27  }
28 
29  /**
30  * Public constructor
31  * @param normal normal
32  * @param distance distance
33  */
34  inline Plane(const Vector3& normal, float distance) {
35  this->normal.set(normal);
36  this->distance = distance;
37  }
38 
39  /**
40  * @return float distance from origin
41  */
42  inline float getDistance() const {
43  return distance;
44  }
45 
46  /**
47  * Set up distance from origin
48  * @param distance distance
49  */
50  inline void setDistance(float distance) {
51  this->distance = distance;
52  }
53 
54  /**
55  * @return normal
56  */
57  inline const Vector3& getNormal() const {
58  return normal;
59  }
60 
61  /**
62  * @return normal
63  */
64  inline void setNormal(const Vector3& normal) {
65  this->normal = normal;
66  }
67 
68  /**
69  * Compute distance from plane
70  * @param point point
71  * @return distance
72  */
73  inline float computeDistance(const Vector3& point) const {
74  return Vector3::computeDotProduct(normal, point) + getDistance();
75  }
76 
77 };
Plane entity, this is not directly connectable with physics engine.
Definition: Plane.h:15
void setNormal(const Vector3 &normal)
Definition: Plane.h:64
Plane(const Vector3 &normal, float distance)
Public constructor.
Definition: Plane.h:34
const Vector3 & getNormal() const
Definition: Plane.h:57
float getDistance() const
Definition: Plane.h:42
float computeDistance(const Vector3 &point) const
Compute distance from plane.
Definition: Plane.h:73
void setDistance(float distance)
Set up distance from origin.
Definition: Plane.h:50
Plane()
Public constructor.
Definition: Plane.h:24
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
Vector3 & set(float x, float y, float z)
Sets this vector3 by its components.
Definition: Vector3.h:70