#ifndef GEOMETRY_UTILS_VECTOR3_H #define GEOMETRY_UTILS_VECTOR3_H #include "VectorNBase.h" namespace geometry_utils { template struct Vector3Base : VectorNBase { Vector3Base() : VectorNBase() {} Vector3Base(T val) : VectorNBase(val) {} Vector3Base(const Vector3Base& in) : VectorNBase(in.data) {} Vector3Base(const boost::array& in) : VectorNBase(in) {} Vector3Base(T (&in)[3]) : VectorNBase(in) {} Vector3Base(const Eigen::Matrix& in) : VectorNBase(in) {} Vector3Base(const VectorNBase& in) : VectorNBase(in) {} Vector3Base(T v1, T v2, T v3) { this->data[0] = v1; this->data[1] = v2; this->data[2] = v3; } T X() const { return this->data[0]; } T Y() const { return this->data[1]; } T Z() const { return this->data[2]; } inline Vector3Base Cross(const Vector3Base& v) const { return Vector3Base(-(*this)(2) * v(1) + (*this)(1) * v(2), (*this)(2) * v(0) - (*this)(0) * v(2), -(*this)(1) * v(0) + (*this)(0) * v(1)); } }; inline Vector3Base operator*(const float& lhs, const Vector3Base& rhs) { return Vector3Base(rhs * lhs); } inline Vector3Base operator*(const double& lhs, const Vector3Base& rhs) { return Vector3Base(rhs * lhs); } template inline VectorNBase Cross(const VectorNBase& v1, const VectorNBase& v2) { return Vector3Base(v1).Cross(v2); } typedef Vector3Base Vector3f; typedef Vector3Base Vec3f; typedef Vector3Base Vector3d; typedef Vector3Base Vec3d; typedef Vector3Base Vector3; typedef Vector3Base Vec3; } #endif