MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
plane.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef MATH_PLANE_HEADER
11#define MATH_PLANE_HEADER
12
13#include "math/defines.h"
14#include "math/vector.h"
15
17
18template <class T> class Plane3;
21
27template <class T>
28class Plane3
29{
30public:
32
33public:
35 Plane3 (void);
36
38 Plane3 (Vec3T const& n, T const& d);
39
41 Plane3 (Vec3T const& n, Vec3T const& p);
42
44 Plane3 (Vec3T const& p1, Vec3T const& p2, Vec3T const& p3);
45
47 T point_dist (Vec3T const& p) const;
48
50 Plane3<T>& invert (void);
51
53 Plane3<T> inverted (void) const;
54
55public:
57 T d;
58};
59
60/* ---------------------------------------------------------------- */
61
62template <class T>
63inline
65{
66}
67
68template <class T>
69inline
70Plane3<T>::Plane3 (Vec3T const& n, T const& d)
71 : n(n), d(d)
72{
73}
74
75template <class T>
76inline
77Plane3<T>::Plane3 (Vec3T const& n, Vec3T const& p)
78 : n(n), d(p.dot(n))
79{
80}
81
82template <class T>
83inline
84Plane3<T>::Plane3 (Vec3T const& p1, Vec3T const& p2, Vec3T const& p3)
85{
86 n = (p2 - p1).cross(p3 - p1).normalize();
87 d = p1.dot(n);
88}
89
90template <class T>
91inline T
93{
94 return p.dot(n) - d;
95}
96
97template <class T>
100{
101 n = -n;
102 d = -d;
103 return *this;
104}
105
106template <class T>
107inline Plane3<T>
109{
110 return Plane3<T>(-n, -d);
111}
112
114
115#endif /* MATH_PLANE_HEADER */
Class that represents a plane in hesse form.
Definition plane.h:29
Plane3< T > inverted(void) const
Returns plane with flipped orientation.
Definition plane.h:108
Plane3< T > & invert(void)
Flips the orientation of the plane.
Definition plane.h:99
Plane3(void)
Creates an uninitialized plane.
Definition plane.h:64
Vector< T, 3 > Vec3T
Definition plane.h:31
Vec3T n
Definition plane.h:56
T point_dist(Vec3T const &p) const
Returns the signed distance from a point to the plane.
Definition plane.h:92
Vector class for arbitrary dimensions and types.
Definition vector.h:87
T dot(Vector< T, N > const &other) const
Dot (or scalar) product between self and another vector.
Definition vector.h:542
Vector< T, N > & normalize(void)
Normalizes self and returns reference to self.
Definition vector.h:448
#define MATH_NAMESPACE_BEGIN
Definition defines.h:15
#define MATH_NAMESPACE_END
Definition defines.h:16