LinearizeAngularTrajectory.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5 * Karlsruhe Institute of Technology (KIT), all rights reserved.
6 *
7 * ArmarX is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ArmarX is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author ()
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
25
26#include "MathUtils.h"
27
28namespace armarx::math
29{
31 linearValue(initialLinearValue)
32 {
33 }
34
35 float
37 {
38 linearValue = linearValue + MathUtils::angleModPI(angle - linearValue);
39 return linearValue;
40 }
41
42 float
44 {
45 return linearValue;
46 }
47
48 std::vector<float>
50 {
51 std::vector<float> result;
52 result.reserve(data.size());
53 if (data.size() == 0)
54 {
55 return result;
56 }
58 for (float v : data)
59 {
60 result.push_back(lat.update(v));
61 }
62 return result;
63 }
64
65 void
67 {
68 if (data.size() == 0)
69 {
70 return;
71 }
73 for (size_t i = 0; i < data.size(); i++)
74 {
75 data.at(i) = lat.update(data.at(i));
76 }
77 }
78
79 std::vector<float>
80 LinearizeAngularTrajectory::Angularize(const std::vector<float>& data, float center)
81 {
82 std::vector<float> result;
83 result.reserve(data.size());
84 for (float v : data)
85 {
86 result.push_back(MathUtils::angleModX(v, center));
87 }
88 return result;
89 }
90
91 void
92 LinearizeAngularTrajectory::AngularizeRef(std::vector<float>& data, float center)
93 {
94 for (size_t i = 0; i < data.size(); i++)
95 {
96 data.at(i) = MathUtils::angleModX(data.at(i), center);
97 }
98 }
99} // namespace armarx::math
static void AngularizeRef(std::vector< float > &data, float center=0)
static std::vector< float > Linearize(const std::vector< float > &data)
static std::vector< float > Angularize(const std::vector< float > &data, float center=0)
static void LinearizeRef(std::vector< float > &data)
static float angleModPI(float value)
Definition MathUtils.h:173
static float angleModX(float value, float center)
Definition MathUtils.h:179
double angle(const Point &a, const Point &b, const Point &c)
Definition point.hpp:109