mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 04:13:33 +08:00
Added vector2.
This commit is contained in:
+13
-10
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user