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 #include <Eigen/Eigen>
27 
28 namespace armarx::math
29 {
31  {
32  public:
33  static void SetRowToValue(Eigen::MatrixXf& matrix, int rowNr, float value)
34  {
35  for (int i = 0; i < matrix.cols(); i++)
36  {
37  matrix(rowNr, i) = value;
38  }
39  }
40 
41  static Eigen::Vector3f CalculateCog3D(const Eigen::MatrixXf& points)
42  {
43  Eigen::Vector3f sum(0, 0, 0);
44 
45  for (int i = 0; i < points.cols(); i++)
46  {
47  sum += points.block<3, 1>(0, i);
48  }
49 
50  return sum / points.cols();
51  }
52 
53  static Eigen::MatrixXf SubtractVectorFromAllColumns3D(const Eigen::MatrixXf& points, const Eigen::Vector3f& vec)
54  {
55  Eigen::MatrixXf matrix(3, points.cols());
56 
57  for (int i = 0; i < points.cols(); i++)
58  {
59  matrix.block<3, 1>(0, i) = points.block<3, 1>(0, i) - vec;
60  }
61 
62  return matrix;
63  }
64 
65  };
66 }
67 
68 
armarx::math::MatrixHelpers::SubtractVectorFromAllColumns3D
static Eigen::MatrixXf SubtractVectorFromAllColumns3D(const Eigen::MatrixXf &points, const Eigen::Vector3f &vec)
Definition: MatrixHelpers.h:53
armarx::math::MatrixHelpers::CalculateCog3D
static Eigen::Vector3f CalculateCog3D(const Eigen::MatrixXf &points)
Definition: MatrixHelpers.h:41
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::math
Definition: LinearizeAngularTrajectory.cpp:27
armarx::math::MatrixHelpers::SetRowToValue
static void SetRowToValue(Eigen::MatrixXf &matrix, int rowNr, float value)
Definition: MatrixHelpers.h:33
armarx::math::MatrixHelpers
Definition: MatrixHelpers.h:30