Plane.hpp
Go to the documentation of this file.
1
2namespace GfxTL
3{
4 template <class PointT>
8
9 template <class PointT>
10 Plane<PointT>::Plane(const PointType& normal, const PointType& origin) : _normal(normal)
11 {
12 _d = -(_normal * origin);
13 }
14
15 template <class PointT>
16 void
17 Plane<PointT>::Set(const PointType& origin, const PointType& normal)
18 {
19 _normal = normal;
20 _d = -(_normal * origin);
21 }
22
23 template <class PointT>
26 {
27 return _normal * p + _d;
28 }
29
30 template <class PointT>
31 void
33 {
34 ScalarType factor = Math<ScalarType>::Sign(_normal * n);
35 _normal *= factor;
36 _d *= factor;
37 }
38
39 template <class PointT>
40 void
42 {
43 *s = p - SignedDistance(p) * _normal;
44 }
45
46 template <class PointT>
47 void
49 {
50 *normal = _normal;
51 }
52
53 template <class PointT>
54 void
56 {
57 _normal = normal;
58 }
59
60 template <class PointT>
63 {
64 return _normal;
65 }
66
67 template <class PointT>
68 const typename Plane<PointT>::PointType&
70 {
71 return _normal;
72 }
73
74 template <class PointT>
75 void
77 {
78 _d = -(_normal * o);
79 }
80
81 template <class PointT>
84 {
85 return -SignedDistance(p) / (_normal * r);
86 }
87}; // namespace GfxTL
static ScalarT Sign(ScalarT s)
Definition MathHelper.h:25
PointType::ScalarType ScalarType
Definition Plane.h:18
void Orient(const PointType &n)
Definition Plane.hpp:32
ScalarType SignedDistance(const PointType &p) const
Definition Plane.hpp:25
PointType & Normal()
Definition Plane.hpp:62
PointT PointType
Definition Plane.h:17
void Project(const PointType &p, PointType *s) const
Definition Plane.hpp:41
ScalarType Intersect(const PointType &p, const PointType &r) const
Definition Plane.hpp:83
void Origin(const PointType &o)
Definition Plane.hpp:76
void Set(const PointType &origin, const PointType &normal)
Definition Plane.hpp:17
Definition AABox.h:10