cgv
Loading...
Searching...
No Matches
plane.h
1#pragma once
2
3#include <cgv/math/vec.h>
4
5namespace cgv {
6 namespace media {
7
12template <class T>
13class plane
14{
15public:
18 plane(int dim = 3)
19 {
20 h.resize(dim+1);
21 }
25 plane(const cgv::math::vec<T> &n, const T &distance)
26 {
27 h.resize(n.size()+1);
28 for (unsigned int i=0; i<n.size(); ++i)
29 h(i) = n(i);
30 h(n.size()) = -distance;
31 }
34 {
36 n.resize(h.size()-1);
37 for (unsigned int i=0; i<n.size(); ++i)
38 n(i) = h(i);
39 return n;
40 }
42 T get_distance() const
43 {
44 return -h(h.size()-1);
45 }
46};
47
48 }
49}
50
A column vector class.
Definition vec.h:28
void resize(unsigned dim)
resize the vector
Definition vec.h:496
unsigned size() const
number of elements
Definition vec.h:59
A plane of arbitrary dimension stored as a homogeneous vector that defines the coefficients of the pl...
Definition plane.h:14
cgv::math::vec< T > get_normal() const
return the normal vector
Definition plane.h:33
plane(const cgv::math::vec< T > &n, const T &distance)
construct from normal vector and distance of plane to origin, which is negated before it is copied to...
Definition plane.h:25
T get_distance() const
return the distance of the plane to the origin
Definition plane.h:42
plane(int dim=3)
construct plane of give dimension allocating a homogenous vector of one dimension mor
Definition plane.h:18
the cgv namespace
Definition print.h:11