Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::util::Curve< V, T > Struct Template Reference

General purpose curve (can be used for gradients, animations, etc...) More...

#include <OxygenEngine/util/curve.h>

Public Types

using Point = CurvePoint< V, T >
 

Public Member Functions

constexpr V eval (const T x) const
 Compute a value on the curve based on control points.
 

Public Attributes

std::vector< Pointcontrol_points
 

Detailed Description

template<class V, class T = float>
struct oe::util::Curve< V, T >

General purpose curve (can be used for gradients, animations, etc...)

Example with an int

{.position = 0.0, .value = 10, .interpolation = CurveInterpolation::LINEAR},
{.position = 0.5, .value = 22, .interpolation = CurveInterpolation::DIRECT},
{.position = 0.8, .value = 22, .interpolation = CurveInterpolation::HOLD_LAST},
{.position = 1.0, .value = 14, .interpolation = CurveInterpolation::LINEAR},
});
int32_t value_at_first_quartile = curve.eval(0.25);
@ HOLD_LAST
Hold last value.
@ DIRECT
No interpolation, directly switch to this value.
@ LINEAR
Do a linear interpolation between last value and this one.
General purpose curve (can be used for gradients, animations, etc...)
Definition curve.h:60
constexpr V eval(const T x) const
Compute a value on the curve based on control points.
Definition curve.h:68

You can use any type for V, but you need to make sure the class overloads operators addition between objects and multiplication with a float

Note
It is assumed the vector is filled with ascending point position

Member Function Documentation

◆ eval()

template<class V , class T = float>
constexpr V oe::util::Curve< V, T >::eval ( const T  x) const
inlineconstexpr

Compute a value on the curve based on control points.

Parameters
xvalue of the abscissa

The documentation for this struct was generated from the following file: