Beziercurve.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#include "Beziercurve.h"
25
26#include <cassert>
27#include <limits>
28
29armarx::Beziercurve::Beziercurve(pointVector controlPoints, size_t degree, size_t index) :
30 m_degree(degree), m_index(index), m_controlPoints(controlPoints)
31{
32}
33
35 m_degree(controlPoints.size() - 1), m_index(0), m_controlPoints(controlPoints)
36{
37}
38
39Eigen::VectorXf
41{
42 assert((t >= 0) && (t <= 1.0 + std::numeric_limits<float>::epsilon()));
43
44 if (m_degree == 0)
45 {
46 return m_controlPoints.at(m_index);
47 }
48
49 Beziercurve left{m_controlPoints, m_degree - 1, m_index};
50 Beziercurve right{m_controlPoints, m_degree - 1, m_index + 1};
51
52 assert((m_degree > 0) && (m_degree < m_controlPoints.size()));
53 assert(m_index < m_controlPoints.size() - m_degree);
54
55 return (1 - t) * left.evaluate(t) + t * right.evaluate(t);
56}
uint8_t index
Eigen::VectorXf evaluate(float t) const
Beziercurve(pointVector controlPoints)
std::vector< Eigen::VectorXf > pointVector
Definition Beziercurve.h:33