blob: 6c19a5aba8ef0cf142d4d9295e7e9af59f033d37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
model/plane.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MODEL_PLANE_H__
#define __INCLUDED_MODEL_PLANE_H__
#include <string>
#include "math/vector3f.h"
namespace model
{
/** @brief A class representing a plane in 3d space
* all points p(x, y, z) on the plane satisfy the general equation
* x*a() + y*b() + z*c() + d() = 0
*/
class Plane
{
public:
/// a plane defined by 3 points in space
Plane(math::Vector3f const & point0, math::Vector3f const &point1, math::Vector3f const &point2);
/// copy constructor
Plane(Plane const & other);
/// normal of the plane, not normalized to lenght 1
inline math::Vector3f const & normal() const
{
return plane_normal;
}
/// the points defining the plane.
/// @param i 0 <= i < 3
inline math::Vector3f const & point(size_t i) const
{
return plane_point[i];
}
/// plane texture
inline std::string & texture()
{
return plane_texture;
}
/// first parameter of the general equation
inline float a() const
{
return plane_normal[0];
}
/// second parameter of the general equation
inline float b() const
{
return plane_normal[1];
}
/// third param of the general equation
inline float c() const
{
return plane_normal[2];
}
/// fourth parameter of the general equation
inline float d() const
{
return pd;
}
/// indidcates if this plane was generated from a detail brush
inline bool & detail()
{
return plane_detail;
}
/// surface flags
inline unsigned int & surface_flags()
{
return plane_surface_flags;
}
private:
math::Vector3f plane_point[3];
math::Vector3f plane_normal;
std::string plane_texture;
unsigned int plane_surface_flags;
bool plane_detail;
float pd;
};
}
#endif // __INCLUDED_MODEL_PLANE_H__
|