diff options
author | Anton Babushkin <anton.babushkin@me.com> | 2013-12-26 23:03:19 +0400 |
---|---|---|
committer | Anton Babushkin <anton.babushkin@me.com> | 2013-12-26 23:03:19 +0400 |
commit | 20c9ce9d6dc119547bc81b9034cebc69a364b565 (patch) | |
tree | da03b71b5db9168b00d26ec3c4a020c4a7b15b12 /src/lib/mathlib/math | |
parent | e103729de308c113d561942335a4bcf20c68a255 (diff) | |
download | px4-firmware-20c9ce9d6dc119547bc81b9034cebc69a364b565.tar.gz px4-firmware-20c9ce9d6dc119547bc81b9034cebc69a364b565.tar.bz2 px4-firmware-20c9ce9d6dc119547bc81b9034cebc69a364b565.zip |
mc_pos_control: replacement for multirotor_pos_control, rewritten to C++ and new mathlib
Diffstat (limited to 'src/lib/mathlib/math')
-rw-r--r-- | src/lib/mathlib/math/Vector.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/mathlib/math/Vector.hpp b/src/lib/mathlib/math/Vector.hpp index b7840170c..c7323c215 100644 --- a/src/lib/mathlib/math/Vector.hpp +++ b/src/lib/mathlib/math/Vector.hpp @@ -262,6 +262,30 @@ public: } /** + * element by element multiplication + */ + const Vector<N> emult(const Vector<N> &v) const { + Vector<N> res; + + for (unsigned int i = 0; i < N; i++) + res.data[i] = data[i] * v.data[i]; + + return res; + } + + /** + * element by element division + */ + const Vector<N> edivide(const Vector<N> &v) const { + Vector<N> res; + + for (unsigned int i = 0; i < N; i++) + res.data[i] = data[i] / v.data[i]; + + return res; + } + + /** * gets the length of this vector squared */ float length_squared() const { |