From 20c9ce9d6dc119547bc81b9034cebc69a364b565 Mon Sep 17 00:00:00 2001 From: Anton Babushkin Date: Thu, 26 Dec 2013 23:03:19 +0400 Subject: mc_pos_control: replacement for multirotor_pos_control, rewritten to C++ and new mathlib --- src/lib/mathlib/math/Vector.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/lib/mathlib') 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 @@ -261,6 +261,30 @@ public: return res; } + /** + * element by element multiplication + */ + const Vector emult(const Vector &v) const { + Vector 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 edivide(const Vector &v) const { + Vector 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 */ -- cgit v1.2.3