first commit
This commit is contained in:
55
include/framework/geometry/plane.h
Normal file
55
include/framework/geometry/plane.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#ifndef __NPLANE__
|
||||
#define __NPLANE__
|
||||
|
||||
|
||||
#include "math/vector.h"
|
||||
|
||||
|
||||
namespace GS {
|
||||
|
||||
/*!
|
||||
@short Plane.
|
||||
ax + by + cz + d = 0
|
||||
@author Emmanuel Julien (ejulien@nworks.fr)
|
||||
*/
|
||||
|
||||
class Plane
|
||||
{
|
||||
float d; ///< Distance to origin.
|
||||
Vector4 p, n; ///< Point in plane and normal.
|
||||
|
||||
public:
|
||||
|
||||
/// Return plane normal.
|
||||
inline const Vector4 &GetNormal() const
|
||||
{ return n; }
|
||||
|
||||
/*!
|
||||
@short Return point distance to plane.
|
||||
|
||||
Distance is signed, positive when the point is in front of the plane,
|
||||
negative otherwise.
|
||||
*/
|
||||
inline float DistanceToPlane(const Vector4 &p) const
|
||||
{ return p.Dot(n) + d; }
|
||||
|
||||
/// Set plane from point/normal and an optional transformation matrix.
|
||||
void Set(const Vector4 *_p, const Vector4 &_n, const Matrix4 * = 0);
|
||||
/// Set plane three vectors and an optional transformation matrix.
|
||||
void Set(const Vector4 _p[3], const Matrix4 * = 0);
|
||||
|
||||
Plane();
|
||||
Plane(const Vector4 &_p, const Vector4 &_n, const Matrix4 *_m = 0)
|
||||
{ Set(&_p, _n, _m); }
|
||||
};
|
||||
|
||||
} // GS
|
||||
|
||||
|
||||
#endif // __NPLANE__
|
||||
Reference in New Issue
Block a user