class EE::Math::Interpolation1d

Overview

A interpolation movement manager, used for movement interpolations. More…

#include <interpolation1d.hpp>

class Interpolation1d {
public:
    // typedefs

    typedef std::function<void(Interpolation1d&)> OnPathEndCallback;
    typedef std::function<void(Interpolation1d&)> OnStepCallback;

    // construction

    Interpolation1d();
    Interpolation1d(std::vector<Point1d> points);
    ~Interpolation1d();

    // methods

    Interpolation1d& add(const Float& pos, const Time& Time = Time::Zero);
    Interpolation1d& edit(const unsigned int& PointNum, const Float& pos, const Time& time = Time::Zero);
    Interpolation1d& erase(const unsigned int& PointNum);
    Interpolation1d& wait(const Float& pos, const Time& time);
    Interpolation1d& waitAndAdd(const Float& pos, const Time& waitTime, const Time& addTime);
    Interpolation1d& start();
    Interpolation1d& start(OnPathEndCallback PathEndCallback, OnStepCallback StepCallback = OnStepCallback());
    Interpolation1d& stop();
    Interpolation1d& setPathEndCallback(OnPathEndCallback PathEndCallback);
    Interpolation1d& setStepCallback(OnStepCallback StepCallback);
    void update(const Time& Elapsed);
    Interpolation1d& reset();
    const Float& getPosition();
    const bool& getLoop() const;
    Interpolation1d& setLoop(const bool& loop);
    Interpolation1d& clear();
    const bool& ended() const;
    Interpolation1d& setSpeed(const Float speed);
    const Float& getSpeed() const;
    const bool& isEnabled() const;
    Interpolation1d& setEnabled(const bool& enabled);
    Interpolation1d& setDuration(const Time& TotTime);
    const Time& getDuration() const;
    const std::vector<Point1d>& getPoints() const;
    std::vector<Point1d> getReversePoints();
    Point1d* getCurrentActual() const;
    Point1d* getCurrentNext() const;
    const unsigned int& getCurrentPositionIndex() const;
    const Float& getFinalPosition();
    Interpolation1d& setType(Ease::Interpolation InterpolationType);
    const int& getType() const;
    UintPtr getData() const;
    void setData(const UintPtr& data);
    Float getCurrentProgress();
    Float getPartialCurrentProgress();
};

Detailed Documentation

A interpolation movement manager, used for movement interpolations.

Methods

Interpolation1d& add(const Float& pos, const Time& Time = Time::Zero)

Add a new point

Interpolation1d& edit(const unsigned int& PointNum, const Float& pos, const Time& time = Time::Zero)

Edit a point

Interpolation1d& erase(const unsigned int& PointNum)

Erase a point

Interpolation1d& wait(const Float& pos, const Time& time)

Same as add( pos, time ).add( pos );

Interpolation1d& waitAndAdd(const Float& pos, const Time& waitTime, const Time& addTime)

Same as add( pos, waitTime ).add( pos, addTime );

Interpolation1d& start()

Start the animation

Interpolation1d& start(OnPathEndCallback PathEndCallback, OnStepCallback StepCallback = OnStepCallback())

Start the animation

Interpolation1d& stop()

Stop the animation

Interpolation1d& setPathEndCallback(OnPathEndCallback PathEndCallback)

Sets a path end callback

Interpolation1d& setStepCallback(OnStepCallback StepCallback)

Sets a step callback

void update(const Time& Elapsed)

Update the movement interpolation

Interpolation1d& reset()

Reset the class

const Float& getPosition()

Returns:

The Current Position

const bool& getLoop() const

Returns:

If movement interpolation is a loop

Interpolation1d& setLoop(const bool& loop)

Set if loop the movement interpolation

Interpolation1d& clear()

Clear all the points

const bool& ended() const

Returns:

If the animation ended

Interpolation1d& setSpeed(const Float speed)

Set the current interpolation speed

const Float& getSpeed() const

Get the current interpolation speed

const bool& isEnabled() const

Returns:

If enabled

Interpolation1d& setDuration(const Time& TotTime)

Instead if setting the time between each waypoint, this set a total time for all the movement interpolation.

const Time& getDuration() const

Returns:

The total duration of the interpolation.

const std::vector<Point1d>& getPoints() const

Returns:

the vector of points

std::vector<Point1d> getReversePoints()

Returns:

the vector of points reversed

Point1d* getCurrentActual() const

Returns:

The Current Node

Point1d* getCurrentNext() const

Returns:

The Next Node

const unsigned int& getCurrentPositionIndex() const

Returns:

The Current Position in the vector

const Float& getFinalPosition()

Returns:

The path end position

Interpolation1d& setType(Ease::Interpolation InterpolationType)

Set the type of interpolation to be used

const int& getType() const

Returns:

The type of the interpolation

Float getCurrentProgress()

Returns:

The current progress percentage (between 0 and 1) of the complete interpolation.

Float getPartialCurrentProgress()

Returns:

The current progress porcentage of the current interpolation. This is the partial progress, not the global of the whole interpolation.