initial commit
This commit is contained in:
51
engine/Math/Plane.h
Normal file
51
engine/Math/Plane.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef BLUECORE_PLANE_H
|
||||
#define BLUECORE_PLANE_H
|
||||
|
||||
#include "Scalar.h"
|
||||
#include "Vector.h"
|
||||
|
||||
namespace BlueCore
|
||||
{
|
||||
template <class T>
|
||||
class PlaneTemplate
|
||||
{
|
||||
public:
|
||||
Vector3Template<T> _n;
|
||||
T _d;
|
||||
|
||||
/**
|
||||
* contructor
|
||||
*/
|
||||
inline PlaneTemplate() : _d( 0. )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* contructor
|
||||
*/
|
||||
inline PlaneTemplate(
|
||||
Vector3Template<T> a,
|
||||
Vector3Template<T> b,
|
||||
Vector3Template<T> c )
|
||||
{
|
||||
_n = (a - b).cross(a - c).normalized();
|
||||
_d = _n.dot( a );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* distance
|
||||
*/
|
||||
inline T distance( const Vector3Template<T> a )
|
||||
{
|
||||
return _n.dot( a ) - _d;
|
||||
}
|
||||
};
|
||||
|
||||
typedef PlaneTemplate<float> PlaneFloat;
|
||||
typedef PlaneTemplate<double> PlaneDouble;
|
||||
typedef PlaneTemplate<Scalar> Plane;
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user