openscenegraph
LinearInterpolator
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13//osgParticle - Copyright (C) 2002 Marco Jez
14
15#ifndef OSGPARTICLE_LINEARINTERPOLATOR
16#define OSGPARTICLE_LINEARINTERPOLATOR
17
19
20#include <osg/CopyOp>
21#include <osg/Object>
22#include <osg/Vec3>
23#include <osg/Vec4>
24
25namespace osgParticle
26{
27
30 {
31 public:
34
36 : Interpolator(copy, copyop) {}
37
39
40 virtual float interpolate(float t, float y1, float y2) const
41 {
42 return y1 + (y2 - y1) * t;
43 }
44
45 virtual osg::Vec2 interpolate(float t, const osg::Vec2& y1, const osg::Vec2& y2) const
46 {
47 return y1 + (y2 - y1) * t;
48 }
49
50 virtual osg::Vec3 interpolate(float t, const osg::Vec3& y1, const osg::Vec3& y2) const
51 {
52 return y1 + (y2 - y1) * t;
53 }
54
55 virtual osg::Vec4 interpolate(float t, const osg::Vec4& y1, const osg::Vec4& y2) const
56 {
57 return y1 + (y2 - y1) * t;
58 }
59
60 protected:
62 };
63
64}
65
66#endif
An abstract base class for implementing interpolators.
Definition osgParticle/Interpolator:30
A linear interpolator.
Definition LinearInterpolator:30
virtual osg::Vec2 interpolate(float t, const osg::Vec2 &y1, const osg::Vec2 &y2) const
Interpolate between 2-dimensional vectors. Default behavior is to interpolate each component separate...
Definition LinearInterpolator:45
LinearInterpolator(const LinearInterpolator &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition LinearInterpolator:35
virtual osg::Vec4 interpolate(float t, const osg::Vec4 &y1, const osg::Vec4 &y2) const
Interpolate between 4-dimensional vectors. Default behavior is to interpolate each component separate...
Definition LinearInterpolator:55
META_Object(osgParticle, LinearInterpolator)
virtual ~LinearInterpolator()
Definition LinearInterpolator:61
virtual float interpolate(float t, float y1, float y2) const
Interpolate between floats. Must be overridden in descendant classes.
Definition LinearInterpolator:40
virtual osg::Vec3 interpolate(float t, const osg::Vec3 &y1, const osg::Vec3 &y2) const
Interpolate between 3-dimensional vectors. Default behavior is to interpolate each component separate...
Definition LinearInterpolator:50
LinearInterpolator()
Definition LinearInterpolator:32
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition Vec2f:29
Definition Vec3f:29
Definition Vec4f:28
Definition AccelOperator:27