Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
G3D::UprightSpline Class Reference

Shortest-path linear velocity spline for camera positions. More...

Inherits G3D::Spline< UprightFrame >.

Public Member Functions

 UprightSpline ()
 
 UprightSpline (const Any &any)
 Constructs an UprightSpline from an Any object. More...
 
void append (float t, const UprightFrame &c)
 Appends a control point at a specific time that must be greater than that of the previous point. More...
 
void append (const UprightFrame &c)
 Appends control point spaced in time based on the previous control point, or spaced at unit intervals if this is the first control point. More...
 
void clear ()
 Erases all control points and times, but retains the state of cyclic and finalInterval. More...
 
void computeIndex (float s, int &i, float &u) const
 Given a time s, finds i and 0 <= u < 1 such that s = time[i] * u + time[i + 1] * (1 - u). More...
 
void deserialize (class BinaryInput &b)
 
float duration () const
 Returns the amount of time covered by this spline in one period. More...
 
UprightFrame evaluate (float s) const
 Return the position at time s. More...
 
void getControl (int i, float &t, UprightFrame &c) const
 Returns the requested control point and time sample based on array index. More...
 
float getFinalInterval () const
 See specification for Spline::finalInterval; this handles the non-positive case. More...
 
size_t hashCode () const
 
UprightSplineoperator= (const Any &any)
 
bool operator== (const Spline< UprightFrame > &other) const
 
void serialize (class BinaryOutput &b) const
 
int size () const
 Number of control points. More...
 
virtual Any toAny (const String &myName) const override
 Note that invoking classes can call setName on the returned value instead of passing a name in. More...
 
Any toAny () const
 

Static Public Member Functions

static Matrix4 computeBasis ()
 Computes the derivative spline basis from the control point version. More...
 

Public Attributes

Array< UprightFramecontrol
 Control points. More...
 
SplineExtrapolationMode extrapolationMode
 If SplineInterpolationMode::CYCLIC, then the control points will be assumed to wrap around. More...
 
float finalInterval
 For a cyclic spline, this is the time elapsed between the last control point and the first. More...
 
SplineInterpolationMode interpolationMode
 
Array< float > time
 Times at which control points occur. More...
 

Protected Member Functions

void computeIndexInBounds (float s, int &i, float &u) const
 Assumes that t0 <= s < tn. More...
 
virtual void correct (UprightFrame &A) const
 Normalize or otherwise adjust this interpolated Control. More...
 
virtual void ensureShortestPath (UprightFrame *A, int N) const override
 Mutates the array of N control points that begins at A. More...
 
void getControls (int i, float *T, UprightFrame *A, int N) const
 Returns a series of N control points and times, fixing boundary issues. More...
 
virtual void init (AnyTableReader &propertyTable)
 Does not invoke verifyDone() on the propertyTable because subclasses may have more properties. More...
 

Protected Attributes

UprightFrame zero
 The additive identity control point. More...
 

Detailed Description

Shortest-path linear velocity spline for camera positions.

Always keeps the camera from rolling.

See also
G3D::UprightSplineManipulator, G3D::UprightFrame

Constructor & Destructor Documentation

◆ UprightSpline() [1/2]

G3D::UprightSpline::UprightSpline ( )

◆ UprightSpline() [2/2]

G3D::UprightSpline::UprightSpline ( const Any any)
explicit

Constructs an UprightSpline from an Any object.

The Any format for UprightSpline is:

controls = (UprightFrame, ...), times = (##, ...), cyclic = bool

The controls and times arrays must have the same length.

Member Function Documentation

◆ append() [1/2]

void G3D::Spline< UprightFrame >::append ( float  t,
const UprightFrame c 
)
inlineinherited

Appends a control point at a specific time that must be greater than that of the previous point.

◆ append() [2/2]

void G3D::Spline< UprightFrame >::append ( const UprightFrame c)
inlineinherited

Appends control point spaced in time based on the previous control point, or spaced at unit intervals if this is the first control point.

◆ clear()

void G3D::Spline< UprightFrame >::clear ( )
inlineinherited

Erases all control points and times, but retains the state of cyclic and finalInterval.

◆ computeBasis()

static Matrix4 G3D::SplineBase::computeBasis ( )
staticinherited

Computes the derivative spline basis from the control point version.

Referenced by G3D::Spline< UprightFrame >::evaluate().

◆ computeIndex()

void G3D::SplineBase::computeIndex ( float  s,
int &  i,
float &  u 
) const
inherited

Given a time s, finds i and 0 <= u < 1 such that s = time[i] * u + time[i + 1] * (1 - u).

Note that i may be outside the bounds of the time and control arrays; use getControl to handle wraparound and extrapolation issues.

This function takes expected O(1) time for control points with uniform time sampled control points or for uniformly distributed random time samples, but may take O( log time.size() ) time in the worst case.

Called from evaluate().

Referenced by G3D::Spline< UprightFrame >::evaluate().

◆ computeIndexInBounds()

void G3D::SplineBase::computeIndexInBounds ( float  s,
int &  i,
float &  u 
) const
protectedinherited

Assumes that t0 <= s < tn.

called by computeIndex.

◆ correct()

virtual void G3D::Spline< UprightFrame >::correct ( UprightFrame A) const
inlineprotectedvirtualinherited

Normalize or otherwise adjust this interpolated Control.

◆ deserialize()

void G3D::UprightSpline::deserialize ( class BinaryInput b)

◆ duration()

float G3D::SplineBase::duration ( ) const
inherited

Returns the amount of time covered by this spline in one period.

For a cyclic spline, this contains the final interval.

Referenced by G3D::Spline< UprightFrame >::getControl().

◆ ensureShortestPath()

virtual void G3D::UprightSpline::ensureShortestPath ( UprightFrame A,
int  N 
) const
inlineoverrideprotectedvirtual

Mutates the array of N control points that begins at A.

It is useful to override this method by one that wraps the values if they are angles or quaternions for which "shortest path" interpolation is significant.

Reimplemented from G3D::Spline< UprightFrame >.

◆ evaluate()

UprightFrame G3D::Spline< UprightFrame >::evaluate ( float  s) const
inlineinherited

Return the position at time s.

The spline is defined outside of the time samples by extrapolation or cycling.

◆ getControl()

void G3D::Spline< UprightFrame >::getControl ( int  i,
float &  t,
UprightFrame c 
) const
inlineinherited

Returns the requested control point and time sample based on array index.

If the array index is out of bounds, wraps (for a cyclic spline) or linearly extrapolates (for a non-cyclic spline), assuming time intervals follow the first or last sample recorded.

Calls correct() on the control point if it was extrapolated.

Returns 0 if there are no control points.

See also
Spline::control and Spline::time for the underlying control point array; Spline::computeIndex to find the index given a time.

◆ getControls()

void G3D::Spline< UprightFrame >::getControls ( int  i,
float *  T,
UprightFrame A,
int  N 
) const
inlineprotectedinherited

Returns a series of N control points and times, fixing boundary issues.

The indices may be assumed to be treated cyclically.

◆ getFinalInterval()

float G3D::SplineBase::getFinalInterval ( ) const
inherited

See specification for Spline::finalInterval; this handles the non-positive case.

Returns 0 if not cyclic.

◆ hashCode()

size_t G3D::Spline< UprightFrame >::hashCode ( ) const
inlineinherited

◆ init()

virtual void G3D::Spline< UprightFrame >::init ( AnyTableReader propertyTable)
inlineprotectedvirtualinherited

Does not invoke verifyDone() on the propertyTable because subclasses may have more properties.

◆ operator=()

UprightSpline& G3D::UprightSpline::operator= ( const Any any)

◆ operator==()

bool G3D::Spline< UprightFrame >::operator== ( const Spline< UprightFrame > &  other) const
inlineinherited

◆ serialize()

void G3D::UprightSpline::serialize ( class BinaryOutput b) const

◆ size()

int G3D::Spline< UprightFrame >::size ( ) const
inlineinherited

Number of control points.

◆ toAny() [1/2]

virtual Any G3D::UprightSpline::toAny ( const String myName) const
overridevirtual

Note that invoking classes can call setName on the returned value instead of passing a name in.

Reimplemented from G3D::Spline< UprightFrame >.

◆ toAny() [2/2]

Any G3D::UprightSpline::toAny ( ) const

Member Data Documentation

◆ control

Array<UprightFrame > G3D::Spline< UprightFrame >::control
inherited

Control points.

Must have the same number of elements as Spline::time.

◆ extrapolationMode

SplineExtrapolationMode G3D::SplineBase::extrapolationMode
inherited

If SplineInterpolationMode::CYCLIC, then the control points will be assumed to wrap around.

If SplineInterpolationMode::LINEAR, then the tangents at the ends of the spline point to the final control points. If SplineInterpolationMode::CLAMP, the end control points will be treated as multiple contol points (so the value remains constant at the ends)

Referenced by G3D::UprightSplineManipulator::extrapolationMode(), G3D::Spline< UprightFrame >::getControl(), G3D::Spline< UprightFrame >::hashCode(), G3D::Spline< UprightFrame >::init(), G3D::Spline< UprightFrame >::operator==(), G3D::UprightSplineManipulator::setExtrapolationMode(), and G3D::Spline< UprightFrame >::toAny().

◆ finalInterval

float G3D::SplineBase::finalInterval
inherited

For a cyclic spline, this is the time elapsed between the last control point and the first.

If less than zero this is assumed to be:

(time[0] - time[1] + . time[time.size() - 1] - time[time.size() - 2]) / 2.

Referenced by G3D::Spline< UprightFrame >::hashCode(), G3D::Spline< UprightFrame >::init(), G3D::Spline< UprightFrame >::operator==(), and G3D::Spline< UprightFrame >::toAny().

◆ interpolationMode

SplineInterpolationMode G3D::SplineBase::interpolationMode
inherited

◆ time

Array<float> G3D::SplineBase::time
inherited

◆ zero

UprightFrame G3D::Spline< UprightFrame >::zero
protectedinherited

The additive identity control point.


documentation generated on Wed Nov 24 2021 08:02:01 using doxygen 1.8.15