Simple game engine with complete export to scripting language
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
784 B

#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