aboutsummaryrefslogtreecommitdiff
path: root/src/lib/mathlib
diff options
context:
space:
mode:
authorAnton Babushkin <anton.babushkin@me.com>2013-12-19 16:58:25 +0400
committerAnton Babushkin <anton.babushkin@me.com>2013-12-19 16:58:25 +0400
commit2df2fd1d252fe1e53d86416070557dec8c996891 (patch)
treeddcd6134ec920442c481fd9de42f3a6d813b3f89 /src/lib/mathlib
parentba612c3ee8b88b9352e7cfa723997887dd736b76 (diff)
downloadpx4-firmware-2df2fd1d252fe1e53d86416070557dec8c996891.tar.gz
px4-firmware-2df2fd1d252fe1e53d86416070557dec8c996891.tar.bz2
px4-firmware-2df2fd1d252fe1e53d86416070557dec8c996891.zip
mathlib minor fixes
Diffstat (limited to 'src/lib/mathlib')
-rw-r--r--src/lib/mathlib/math/Matrix.hpp8
-rw-r--r--src/lib/mathlib/math/Quaternion.hpp36
-rw-r--r--src/lib/mathlib/math/Vector.hpp14
3 files changed, 11 insertions, 47 deletions
diff --git a/src/lib/mathlib/math/Matrix.hpp b/src/lib/mathlib/math/Matrix.hpp
index 67214133a..47929ffcb 100644
--- a/src/lib/mathlib/math/Matrix.hpp
+++ b/src/lib/mathlib/math/Matrix.hpp
@@ -129,7 +129,7 @@ public:
*/
const Matrix<M, N> &operator =(const Matrix<M, N> &m) {
memcpy(data, m.data, sizeof(data));
- return *reinterpret_cast<Matrix<M, N>*>(this);
+ return *static_cast<Matrix<M, N>*>(this);
}
/**
@@ -158,7 +158,7 @@ public:
for (unsigned int i = 0; i < N; i++)
for (unsigned int j = 0; j < M; j++)
data[i][j] += m.data[i][j];
- return *reinterpret_cast<Matrix<M, N>*>(this);
+ return *static_cast<Matrix<M, N>*>(this);
}
/**
@@ -176,7 +176,7 @@ public:
for (unsigned int i = 0; i < N; i++)
for (unsigned int j = 0; j < M; j++)
data[i][j] -= m.data[i][j];
- return *reinterpret_cast<Matrix<M, N>*>(this);
+ return *static_cast<Matrix<M, N>*>(this);
}
/**
@@ -194,7 +194,7 @@ public:
for (unsigned int i = 0; i < M; i++)
for (unsigned int j = 0; j < N; j++)
data[i][j] *= num;
- return *reinterpret_cast<Matrix<M, N>*>(this);
+ return *static_cast<Matrix<M, N>*>(this);
}
Matrix<M, N> operator /(const float num) const {
diff --git a/src/lib/mathlib/math/Quaternion.hpp b/src/lib/mathlib/math/Quaternion.hpp
index 1b0cb3c41..3735fb3d3 100644
--- a/src/lib/mathlib/math/Quaternion.hpp
+++ b/src/lib/mathlib/math/Quaternion.hpp
@@ -73,42 +73,6 @@ public:
Quaternion(const float *v) : Vector(v) {
}
- /**
- * access to elements by index
- */
- /*
- inline float &operator ()(unsigned int i) {
- return *(&a + i);
- }
- */
-
- /**
- * access to elements by index
- */
- /*
- inline const float &operator ()(unsigned int i) const {
- return *(&a + i);
- }
- */
-
- /**
- * addition
- */
- /*
- const Quaternion operator +(const Quaternion &q) const {
- return Quaternion(a + q.a, b + q.b, c + q.c, d + q.d);
- }
- */
-
- /**
- * subtraction
- */
- /*
- const Quaternion operator -(const Quaternion &q) const {
- return Quaternion(a - q.a, b - q.b, c - q.c, d - q.d);
- }
- */
-
Quaternion derivative(const Vector<3> &w) {
float dataQ[] = {
data[0], -data[1], -data[2], -data[3],
diff --git a/src/lib/mathlib/math/Vector.hpp b/src/lib/mathlib/math/Vector.hpp
index 2df87c74b..8d754a321 100644
--- a/src/lib/mathlib/math/Vector.hpp
+++ b/src/lib/mathlib/math/Vector.hpp
@@ -135,7 +135,7 @@ public:
*/
const Vector<N> &operator =(const Vector<N> &v) {
memcpy(data, v.data, sizeof(data));
- return *reinterpret_cast<const Vector<N>*>(this);
+ return *static_cast<const Vector<N>*>(this);
}
/**
@@ -180,7 +180,7 @@ public:
* uniform scaling
*/
const Vector<N> operator /(const float num) const {
- Vector<N> temp(*reinterpret_cast<const Vector<N>*>(this));
+ Vector<N> temp(*static_cast<const Vector<N>*>(this));
return temp /= num;
}
@@ -190,7 +190,7 @@ public:
const Vector<N> &operator +=(const Vector<N> &v) {
for (unsigned int i = 0; i < N; i++)
data[i] += v(i);
- return *reinterpret_cast<const Vector<N>*>(this);
+ return *static_cast<const Vector<N>*>(this);
}
/**
@@ -199,7 +199,7 @@ public:
const Vector<N> &operator -=(const Vector<N> &v) {
for (unsigned int i = 0; i < N; i++)
data[i] -= v(i);
- return *reinterpret_cast<const Vector<N>*>(this);
+ return *static_cast<const Vector<N>*>(this);
}
/**
@@ -208,7 +208,7 @@ public:
const Vector<N> &operator *=(const float num) {
for (unsigned int i = 0; i < N; i++)
data[i] *= num;
- return *reinterpret_cast<const Vector<N>*>(this);
+ return *static_cast<const Vector<N>*>(this);
}
/**
@@ -217,7 +217,7 @@ public:
const Vector<N> &operator /=(const float num) {
for (unsigned int i = 0; i < N; i++)
data[i] /= num;
- return *reinterpret_cast<const Vector<N>*>(this);
+ return *static_cast<const Vector<N>*>(this);
}
/**
@@ -241,7 +241,7 @@ public:
* gets the length of this vector
*/
float length() const {
- return sqrtf(*this * *reinterpret_cast<const Vector<N>*>(this));
+ return sqrtf(*this * *static_cast<const Vector<N>*>(this));
}
/**