MatrixHelpers.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Core
17 * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
18 * @date 2015
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <math.h>
26 
27 #include <Eigen/Eigen>
28 
29 namespace armarx::math
30 {
32  {
33  public:
34  static void
35  SetRowToValue(Eigen::MatrixXf& matrix, int rowNr, float value)
36  {
37  for (int i = 0; i < matrix.cols(); i++)
38  {
39  matrix(rowNr, i) = value;
40  }
41  }
42 
43  static Eigen::Vector3f
44  CalculateCog3D(const Eigen::MatrixXf& points)
45  {
46  Eigen::Vector3f sum(0, 0, 0);
47 
48  for (int i = 0; i < points.cols(); i++)
49  {
50  sum += points.block<3, 1>(0, i);
51  }
52 
53  return sum / points.cols();
54  }
55 
56  static Eigen::MatrixXf
57  SubtractVectorFromAllColumns3D(const Eigen::MatrixXf& points, const Eigen::Vector3f& vec)
58  {
59  Eigen::MatrixXf matrix(3, points.cols());
60 
61  for (int i = 0; i < points.cols(); i++)
62  {
63  matrix.block<3, 1>(0, i) = points.block<3, 1>(0, i) - vec;
64  }
65 
66  return matrix;
67  }
68  };
69 } // namespace armarx::math
armarx::math::MatrixHelpers::SubtractVectorFromAllColumns3D
static Eigen::MatrixXf SubtractVectorFromAllColumns3D(const Eigen::MatrixXf &points, const Eigen::Vector3f &vec)
Definition: MatrixHelpers.h:57
armarx::math::MatrixHelpers::CalculateCog3D
static Eigen::Vector3f CalculateCog3D(const Eigen::MatrixXf &points)
Definition: MatrixHelpers.h:44
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::math
Definition: LinearizeAngularTrajectory.cpp:28
armarx::math::MatrixHelpers::SetRowToValue
static void SetRowToValue(Eigen::MatrixXf &matrix, int rowNr, float value)
Definition: MatrixHelpers.h:35
armarx::math::MatrixHelpers
Definition: MatrixHelpers.h:31