Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Types::Math::Stop< T > Struct Template Reference

Represents a control point in a gradient or interpolation ramp. More...

#include <Stop.hpp>

Public Member Functions

 Stop ()=default
 Default constructor.
 
 Stop (float position, T value)
 Constructs a stop with specified position and value.
 
bool operator== (const Stop< T > &other) const
 Equality comparison operator.
 
bool operator!= (const Stop< T > &other) const
 Inequality comparison operator.
 
bool operator< (const Stop< T > &other) const
 Less-than comparison operator based on position.
 
bool operator> (const Stop< T > &other) const
 Greater-than comparison operator based on position.
 
bool operator<= (const Stop< T > &other) const
 Less-than-or-equal comparison operator based on position.
 
bool operator>= (const Stop< T > &other) const
 Greater-than-or-equal comparison operator based on position.
 

Public Attributes

float position
 Position of the stop along the parameter axis.
 
value
 Value associated with this stop.
 

Detailed Description

template<typename T>
struct Infinity::Types::Math::Stop< T >

Represents a control point in a gradient or interpolation ramp.

Stop defines a single control point along a one-dimensional parameter space, associating a position (typically in the range [0, 1]) with a value of any type. Stops are the fundamental building blocks of Ramp objects, which provide smooth interpolation between values across a parameter range.

Common use cases in procedural generation:

  • Color gradients for textures and materials
  • Height curves for terrain generation
  • Animation curves and easing functions
  • Parameter transitions in procedural effects
  • Falloff curves for blending operations
  • Density distributions for particle systems

Stops can hold any type of value (floats, vectors, colors, etc.) and are typically sorted by position when used in a Ramp. The comparison operators are provided to facilitate sorting by position.

Example usage:

// Scalar gradient stops
ValueStop start(0.0f, 0.0f); // At position 0, value is 0
ValueStop middle(0.5f, 1.0f); // At position 0.5, value is 1
ValueStop end(1.0f, 0.5f); // At position 1, value is 0.5
// Color gradient stops (using Vector3 for RGB)
Value3Stop black(0.0f, Vector3(0, 0, 0));
Value3Stop red(0.5f, Vector3(1, 0, 0));
Value3Stop white(1.0f, Vector3(1, 1, 1));
// Stops can be sorted by position
std::vector<ValueStop> stops = {end, start, middle};
std::sort(stops.begin(), stops.end()); // Sorts by position
// Used in a Ramp for interpolation
Ramp<float> heightCurve;
heightCurve.addStop(ValueStop(0.0f, 0.0f));
heightCurve.addStop(ValueStop(0.3f, 0.8f));
heightCurve.addStop(ValueStop(1.0f, 0.2f));
float height = heightCurve.evaluate(0.5f);
Interpolated gradient for smoothly transitioning between values.
Definition Ramp.hpp:90
Stop< float > ValueStop
Alias for Stop<float>, a scalar gradient control point.
Definition Stop.hpp:196
t_Vector3< float > Vector3
Alias for t_Vector3<float>, the default 3D vector type.
Definition Vector3.hpp:580
Represents a control point in a gradient or interpolation ramp.
Definition Stop.hpp:64
Template Parameters
TThe type of value stored at this stop (e.g., float, Vector3, Vector4).
See also
Ramp
ValueStop, Value2Stop, Value3Stop, Value4Stop

Constructor & Destructor Documentation

◆ Stop() [1/2]

template<typename T >
Infinity::Types::Math::Stop< T >::Stop ( )
default

Default constructor.

Creates a stop with default-initialized position and value.

◆ Stop() [2/2]

template<typename T >
Infinity::Types::Math::Stop< T >::Stop ( float  position,
value 
)
inline

Constructs a stop with specified position and value.

Parameters
positionThe position along the parameter axis (typically 0-1).
valueThe value at this position.
Stop<float> stop(0.5f, 1.0f); // Midpoint with value 1.0
Stop<Vector3> colorStop(0.25f, Vector3(1, 0, 0)); // Red at 25%

Member Function Documentation

◆ operator!=()

template<typename T >
bool Infinity::Types::Math::Stop< T >::operator!= ( const Stop< T > &  other) const
inline

Inequality comparison operator.

Parameters
otherThe stop to compare against.
Returns
true if positions or values differ.

◆ operator<()

template<typename T >
bool Infinity::Types::Math::Stop< T >::operator< ( const Stop< T > &  other) const
inline

Less-than comparison operator based on position.

Compares only the position, not the value. Useful for sorting stops along a ramp.

Parameters
otherThe stop to compare against.
Returns
true if this stop's position is less than other's position.
std::vector<ValueStop> stops;
// ... add stops ...
std::sort(stops.begin(), stops.end()); // Sorts by position

◆ operator<=()

template<typename T >
bool Infinity::Types::Math::Stop< T >::operator<= ( const Stop< T > &  other) const
inline

Less-than-or-equal comparison operator based on position.

Compares only the position, not the value.

Parameters
otherThe stop to compare against.
Returns
true if this stop's position is less than or equal to other's position.

◆ operator==()

template<typename T >
bool Infinity::Types::Math::Stop< T >::operator== ( const Stop< T > &  other) const
inline

Equality comparison operator.

Two stops are equal if both their positions and values are equal.

Parameters
otherThe stop to compare against.
Returns
true if positions and values are equal.

◆ operator>()

template<typename T >
bool Infinity::Types::Math::Stop< T >::operator> ( const Stop< T > &  other) const
inline

Greater-than comparison operator based on position.

Compares only the position, not the value.

Parameters
otherThe stop to compare against.
Returns
true if this stop's position is greater than other's position.

◆ operator>=()

template<typename T >
bool Infinity::Types::Math::Stop< T >::operator>= ( const Stop< T > &  other) const
inline

Greater-than-or-equal comparison operator based on position.

Compares only the position, not the value.

Parameters
otherThe stop to compare against.
Returns
true if this stop's position is greater than or equal to other's position.

Member Data Documentation

◆ position

template<typename T >
float Infinity::Types::Math::Stop< T >::position

Position of the stop along the parameter axis.

Typically in the range [0, 1] but can be any value. This determines where along the ramp this control point is located. Stops are usually sorted by position for efficient interpolation.

◆ value

template<typename T >
T Infinity::Types::Math::Stop< T >::value

Value associated with this stop.

The value to interpolate to/from at this position. Can be any type that supports interpolation (scalars, vectors, colors, etc.).