Fawkes API Fawkes Development Version
linear.cpp
1
2/***************************************************************************
3 * linear.cpp - Linear interpolator
4 *
5 * Created: Tue Nov 18 11:13:13 2008
6 * Copyright 2008 Tim Niemueller [www.niemueller.de]
7 * 2008 Graeme McPhillips
8 *
9 ****************************************************************************/
10
11/* This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. A runtime exception applies to
15 * this software (see LICENSE.GPL_WRE file mentioned below for details).
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
21 *
22 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23 */
24
25#include <utils/math/interpolation/linear.h>
26
27namespace fawkes {
28
29/** @class LinearInterpolator <utils/math/interpolation/linear.h>
30 * Linear value interpolator.
31 * The interpolator creates intermediate points given a starting and and
32 * end point and time constraints. Times are supplied in a discrete unit like
33 * miliseconds or microseconds.
34 * The values are interpolated on a straight line between the starting and the
35 * end point.
36 *
37 * The calculation is executed with the following equation:
38 * \f[
39 * \frac{t_\mathrm{current}}{t_\mathrm{end}} \cdot (v_\mathrm{end} - v_\mathrm{start}) + v_\mathrm{start}
40 * \f]
41 *
42 * @author Tim Niemueller
43 * @author Graeme McPhillips
44 * @author Stephen Marais
45 */
46
47float
49 float t_end,
50 float t_step,
51 float v_start,
52 float v_end)
53{
54 return (t_current / t_end) * (v_end - v_start) + v_start;
55}
56
57} // end namespace fawkes
virtual float interpolate(float t_current, float t_end, float t_step, float v_start, float v_end)
Interpolate a point at a specific time.
Definition: linear.cpp:48
Fawkes library namespace.