From 81787e9004377016236865e95b95707ed6cf1d0b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 2 Mar 2008 12:23:48 +0000 Subject: initial (buggy) support for .map models --- src/math/plane3f.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/math/plane3f.h (limited to 'src/math/plane3f.h') diff --git a/src/math/plane3f.h b/src/math/plane3f.h new file mode 100644 index 0000000..ddaef16 --- /dev/null +++ b/src/math/plane3f.h @@ -0,0 +1,50 @@ +/* + math/plane3f.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_MATH_PLANE3F_H__ +#define __INCLUDED_MATH_PLANE3F_H__ + +#include "math/vector3f.h" + +namespace math +{ + +/** @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 Plane3f +{ +public: + /// a plane defined by 3 points in space + Plane3f(Vector3f const & point0, Vector3f const &point1, Vector3f const &point2); + /// copy constructor + Plane3f(Plane3f const & other); + + /// normal of the plane, not normalized to lenght 1 + inline Vector3f const & normal() const { return plane_normal; } + /// the points defining the plane. + /// @param i 0 <= i < 3 + inline Vector3f const & point(size_t i) const { return plane_point[i]; } + + /// 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; } + +private: + Vector3f plane_point[3]; + Vector3f plane_normal; + float pd; +}; + +} + +#endif // __INCLUDED_MATH_PLANE3F_H__ -- cgit v1.2.3