Added vector2.

This commit is contained in:
jgoppert
2015-11-07 14:27:12 -05:00
parent ace2751715
commit 9b995e19f3
12 changed files with 160 additions and 45 deletions
+13 -10
View File
@@ -20,6 +20,9 @@ template<typename Type>
class Vector3 : public Vector<Type, 3>
{
public:
typedef Matrix<Type, 3, 1> Matrix31;
virtual ~Vector3() {};
Vector3() :
@@ -27,12 +30,7 @@ public:
{
}
Vector3(const Vector<Type, 3> & other) :
Vector<Type, 3>(other)
{
}
Vector3(const Matrix<Type, 3, 1> & other) :
Vector3(const Matrix31 & other) :
Vector<Type, 3>(other)
{
}
@@ -50,14 +48,19 @@ public:
v(2) = z;
}
Vector3 cross(const Vector3 & b) const {
Vector3 cross(const Matrix31 & b) const {
const Vector3 &a(*this);
Vector3 c;
c(0) = a(1)*b(2) - a(2)*b(1);
c(1) = -a(0)*b(2) + a(2)*b(0);
c(2) = a(0)*b(1) - a(1)*b(0);
c(0) = a(1)*b(2,0) - a(2)*b(1,0);
c(1) = -a(0)*b(2,0) + a(2)*b(0,0);
c(2) = a(0)*b(1,0) - a(1)*b(0,0);
return c;
}
Vector3 operator%(const Matrix31 & b) const {
return (*this).cross(b);
}
};
typedef Vector3<float> Vector3f;