52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#ifndef BLUECORE_TRANSFORMATION_H
|
|
#define BLUECORE_TRANSFORMATION_H
|
|
|
|
#include "Quaternion.h"
|
|
#include "Vector.h"
|
|
|
|
namespace BlueCore
|
|
{
|
|
template<class T> class TransformationTemplate
|
|
{
|
|
public:
|
|
|
|
QuaternionTemplate<T> rotation;
|
|
Vector3Template<T> translation;
|
|
|
|
TransformationTemplate()
|
|
{
|
|
}
|
|
|
|
template<class S> TransformationTemplate(
|
|
const QuaternionTemplate<S> &rot) :
|
|
rotation(rot)
|
|
{
|
|
}
|
|
|
|
template<class S> TransformationTemplate(
|
|
const Vector3Template<S> &trans) :
|
|
translation(trans)
|
|
{
|
|
}
|
|
|
|
template<class R, class S> TransformationTemplate(
|
|
const QuaternionTemplate<S> &rot,
|
|
const Vector3Template<S> &trans) :
|
|
rotation(rot), translation(trans)
|
|
{
|
|
}
|
|
|
|
template<class S> Vector3Template<T> transform(const Vector3Template<S> &v)
|
|
{
|
|
return rotation.apply(v) + translation;
|
|
}
|
|
};
|
|
|
|
typedef TransformationTemplate<float> TransformationFloat;
|
|
typedef TransformationTemplate<double> TransformationDouble;
|
|
typedef TransformationTemplate<Scalar> Transformation;
|
|
|
|
} // namespace BlueCore
|
|
|
|
#endif /*TRANSFORMATION_H_*/
|