Developer Documentation

BezierInterpolationT_impl.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44 #include "AnimationHelper.hh"
45 #include <utility>
46
47 //-----------------------------------------------------------------------------------------------------
48
49 template<typename Scalar>
50 std::vector<Scalar> BezierInterpolationT<Scalar>::getValue(Scalar _atX) {
51 float bezierParam = AnimationHelper::approximateCubicBezierParameter<Scalar>(_atX, P0_.first, P1_.first, C0_.first, C1_.first);
52 return AnimationHelper::evaluateBezier<Scalar>(bezierParam, P0_.second, P1_.second, C0_.second, C1_.second);
53 }
54
55 //-----------------------------------------------------------------------------------------------------
56
57 template<typename Scalar>
58 Scalar BezierInterpolationT<Scalar>::getMaxInput() {
59 typedef std::vector<Scalar> Scalars;
60
61 Scalars p0_x; p0_x.push_back(P0_.first);
62 Scalars p1_x; p1_x.push_back(P1_.first);
63 Scalars c0_x; c0_x.push_back(C0_.first);
64 Scalars c1_x; c1_x.push_back(C1_.first);
65
66 return AnimationHelper::evaluateBezier<Scalar>(1.0f, p0_x, p1_x, c0_x, c1_x)[0];
67 }
68
69 //-----------------------------------------------------------------------------------------------------
70
71 template<typename Scalar>
72 Scalar BezierInterpolationT<Scalar>::getMinInput() {
73 typedef std::vector<Scalar> Scalars;
74
75 Scalars p0_x; p0_x.push_back(P0_.first);
76 Scalars p1_x; p1_x.push_back(P1_.first);
77 Scalars c0_x; c0_x.push_back(C0_.first);
78 Scalars c1_x; c1_x.push_back(C1_.first);
79
80 return AnimationHelper::evaluateBezier<Scalar>(0.0f, p0_x, p1_x, c0_x, c1_x)[0];
81 }
82
83 //-----------------------------------------------------------------------------------------------------
84
85 template<typename Scalar>
86 typename BezierInterpolationT<Scalar>::Point&
87 BezierInterpolationT<Scalar>::P0(){
88 return P0_;
89 }
90
91 //-----------------------------------------------------------------------------------------------------
92
93 template<typename Scalar>
94 typename BezierInterpolationT<Scalar>::Point&
95 BezierInterpolationT<Scalar>::C0(){
96 return C0_;
97 }
98
99 //-----------------------------------------------------------------------------------------------------
100
101 template<typename Scalar>
102 typename BezierInterpolationT<Scalar>::Point&
103 BezierInterpolationT<Scalar>::C1(){
104 return C1_;
105 }
106
107 //-----------------------------------------------------------------------------------------------------
108
109 template<typename Scalar>
110 typename BezierInterpolationT<Scalar>::Point&
111 BezierInterpolationT<Scalar>::P1(){
112 return P1_;
113 }
114
115 //-----------------------------------------------------------------------------------------------------
BezierInterpolationT
Definition: InterpolationT.hh:71