SplinePath.h
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#pragma once
25
26#include <array>
27
28#include <QPainterPath>
29#include <QPointF>
30
32
33namespace armarx
34{
35
36 using QPoint2Array = std::array<QPointF, 2>;
37 using QPoint4Array = std::array<QPointF, 4>;
38
40 {
41 public:
42 SplinePath();
43
44 /**
45 * @brief simplePath Constructs a cubic Beziercurve with an arbitrary number of control points.
46 * @param simpleControlPoints The given control points
47 * @return A cubic Beziercurve in the convex hull of the simpleControlPoints.
48 */
49 static QPainterPath simplePath(QPointList simpleControlPoints);
50 /**
51 * @brief complexPath Constructs a cubic Beziercurve with a correctly specified vector of control points.
52 * @param fullControlPoints The control points of the curve. Their size needs to be equal to 1 mod 3.
53 * @return Beziercurve as implied by fullControlPoints.
54 */
55 static QPainterPath complexPath(QPointList fullControlPoints);
56
57 private:
58 /**
59 * @brief relativeDistance Factor needed for calculation of smooth transitions.
60 */
61 static constexpr float relativeDistance = 0.5;
62
63 /**
64 * @brief line Turns the given two points into three control points, by putting one in the middle of the
65 * straight line between start and end.
66 * @param start
67 * @param end
68 * @return The last two points of the three calculated points. That is: middle, end.
69 */
70 static QPoint2Array line(QPointF start, QPointF end);
71 /**
72 * @brief smoothTransition Takes three simple control points of which one is at the transition of two
73 * partial splines. Adds one point between start and middle and one between middle and end. All given
74 * and calculated points are returned except start.
75 * @param start
76 * @param middle
77 * @param end
78 * @return The last four of the five calculated points. That is: new1, middle, new2, end.
79 */
80 static QPoint4Array smoothTransition(QPointF start, QPointF middle, QPointF end);
81
82 static void pathToString(QPainterPath path);
83 };
84} // namespace armarx
static QPainterPath complexPath(QPointList fullControlPoints)
complexPath Constructs a cubic Beziercurve with a correctly specified vector of control points.
static QPainterPath simplePath(QPointList simpleControlPoints)
simplePath Constructs a cubic Beziercurve with an arbitrary number of control points.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::array< QPointF, 2 > QPoint2Array
Definition SplinePath.h:36
std::array< QPointF, 4 > QPoint4Array
Definition SplinePath.h:37
QList< QPointF > QPointList
Definition Transition.h:38