CubicFunction.cpp 731 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "API/CubicFunction.h"

using namespace spline;

CubicFunction::CubicFunction(const Vector3& a, const Vector3& b, const Vector3& c, const Vector3& d, const Real tBegin, const Real tEnd)
	: a_(a), b_(b), c_(c), d_(d), tBegin_(tBegin), tEnd_(tEnd)
{
	// NOTHING
}

CubicFunction::~CubicFunction()
{
	// NOTHING
}

bool CubicFunction::Evaluate(const Real t, Vector3& result) const
{
	if(tBegin_ <= t && t <= tEnd_)
	{
		Real dt = (t - tBegin_);
		result =  a_ + b_ * dt +  c_ * dt * dt + d_ * dt * dt * dt;
		return true;
	}
	else // t out of bounds
	{
		return false;
	}
}

30
Real CubicFunction::MinBound() const
31
{
32
	return tBegin_;
33
}
34
35
36
37
38

Real CubicFunction::MaxBound() const
{
	return tEnd_;
}