Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
ParabolicEase Class Reference

Ease in and out based on a linear velocity. More...

#include <ParabolicEase.h>

Public Member Functions

 ParabolicEase (Real easeInTime=0.0f, Real easeOutTime=0.0f)
 
void setEaseTimes (Real easeInTime, Real easeOutTime)
 Initialize the ease-in/ease-out function.
 
Real operator() (Real param) const
 Evaluate the ease-in/ease-out function at time.
 

Detailed Description

Ease in and out based on a linear velocity.

This ends up being a function that is parabolic at both ends and a linear middle section with respect to position.

velocity(0.0) = 0.0 velocity(in) = v0 velocity(out) = v0 velocity(1.0) = 0.0

From 0.0->in velocity is linearly increasing. From out->1.0 velocity is linearly decreasing.

velocity(t) = v0*t/in t = [0, in] Linear increasing segment = v0 t = (in, out] Constant segment = (1-t)*v0/(1-out) t = (out, 1.0] Linear decreasing segment

We need to calculate v0. We want the total distance covered to be 1.0.

1 = integral(velocity(t), 0, 1) 1 = integral(velocity(t), 0, in) + integral(velocity(t), in, out) + integral(velocity(t), out, 1.0) 1 = v0*in/2 + v0*(out - in) + v0*(1 - out)/2 = v0*(out-in+1)/2 v0 = 2/(out-in+1)

Now we can calculate the distance function.

d(0->in) = integral(velocity(t), 0, s) = v0*s*s/(2*in) d(in->out) = d(0->in) + integral(velocity(t), in, s) = (v0*in/2) + (v0*(s - in)) d(out->1) = d(0->in) + d(in->out) + integral(velocity(t), out, s) = (v0*in/2) + (v0*(out - in)) + (s-s*s/2-out+out*out/2)*v0/(1-out)

Definition at line 68 of file ParabolicEase.h.

Constructor & Destructor Documentation

◆ ParabolicEase()

ParabolicEase::ParabolicEase ( Real easeInTime = 0.0f,
Real easeOutTime = 0.0f )
inlineexplicit

Definition at line 71 of file ParabolicEase.h.

Member Function Documentation

◆ operator()()

Real ParabolicEase::operator() ( Real param) const

Evaluate the ease-in/ease-out function at time.

Parameters
param.
paramis normalized from 0 to 1.

Definition at line 75 of file ParabolicEase.cpp.

◆ setEaseTimes()

void ParabolicEase::setEaseTimes ( Real easeInTime,
Real easeOutTime )

Initialize the ease-in/ease-out function.

Parameters
easeInTime/

param easeOutTime is the amount of time to accomplish the transition. The time is normalized from 0 to 1.

Definition at line 53 of file ParabolicEase.cpp.


The documentation for this class was generated from the following files: