2D Curve. More...
#include <decCurve2D.h>
Public Member Functions | |
Constructors and Destructors | |
| decCurve2D () | |
| Creates a new curve. | |
| decCurve2D (const decCurve2D &curve) | |
| Creates a new curve. | |
| ~decCurve2D () | |
| Cleans up the curve. | |
Management | |
| int | GetPointCount () const |
| Retrieves the number of points. | |
| const decVector2 & | GetPointAt (int position) const |
| Retrieves the point at the given position. | |
| int | IndexOfPointClosestTo (float coordinate, float threshold=1e-5f) const |
| Retrieves the index of the point closest to an x coordinate in respect to a given margin. | |
| int | IndexOfPointBefore (float coordinate) const |
| Retrieves the index of the point with the x coordinates matching the given x coordinate or the point which lies closest on the smaller side. | |
| int | AddPoint (const decVector2 &point, float threshold=1e-5f) |
| Adds a point returning the index where it has been added. | |
| void | RemovePointFrom (int position) |
| Removes a point from the given position. | |
| void | RemoveAllPoints () |
| Removes all points. | |
| void | SetDefaultCurve () |
| Clears the curve adding the points (0,0) and (1,1). | |
| void | OffsetPointsBy (float offset) |
| Offsets the Y coordinate of all curve points. | |
| void | ScalePointsBy (float scale) |
| Scales the Y coordinate of all curve points. | |
| float | EvaluateConstant (float coordinate) const |
| Evaluates the curve using constant interpolation. | |
| float | EvaluateLinear (float coordinate) const |
| Evaluates the curve using linear interpolation. | |
| decCurve2D & | operator= (const decCurve2D &curve) |
| Sets this curve equal to another curve. | |
2D Curve.
Defines a curve in 2 dimensions. The curve is defined using a set of points. Points inserted are sorted using the X coordinate. Points which are identical are merged with the newly added point overwriting the old point. Two evaluation methods are provided to evaluate the curve using either constant or linear interpolation. Using constant interpolation the value of a curve point corresponds to the Y coordinate of the point right prior to it. Linear interpolation slides the Y value gradually between points. For cubic interpolation an additional class is used since this requires storing point parameters for evaluation and doing this for each evaluation of a point is slow.
| decCurve2D::decCurve2D | ( | ) |
Creates a new curve.
| decCurve2D::decCurve2D | ( | const decCurve2D & | curve ) |
Creates a new curve.
| decCurve2D::~decCurve2D | ( | ) |
Cleans up the curve.
| int decCurve2D::AddPoint | ( | const decVector2 & | point, |
| float | threshold = 1e-5f |
||
| ) |
Adds a point returning the index where it has been added.
| float decCurve2D::EvaluateConstant | ( | float | coordinate ) | const |
Evaluates the curve using constant interpolation.
| float decCurve2D::EvaluateLinear | ( | float | coordinate ) | const |
Evaluates the curve using linear interpolation.
| const decVector2& decCurve2D::GetPointAt | ( | int | position ) | const |
Retrieves the point at the given position.
| int decCurve2D::GetPointCount | ( | ) | const [inline] |
Retrieves the number of points.
| int decCurve2D::IndexOfPointBefore | ( | float | coordinate ) | const |
Retrieves the index of the point with the x coordinates matching the given x coordinate or the point which lies closest on the smaller side.
This method can be used to find the interval a point is located in by returning the most prior point. Retrieves -1 if there are no points satisfying this criteria.
| int decCurve2D::IndexOfPointClosestTo | ( | float | coordinate, |
| float | threshold = 1e-5f |
||
| ) | const |
Retrieves the index of the point closest to an x coordinate in respect to a given margin.
If no such point can be found -1 is returned.
| void decCurve2D::OffsetPointsBy | ( | float | offset ) |
Offsets the Y coordinate of all curve points.
| decCurve2D& decCurve2D::operator= | ( | const decCurve2D & | curve ) |
Sets this curve equal to another curve.
| void decCurve2D::RemoveAllPoints | ( | ) |
Removes all points.
| void decCurve2D::RemovePointFrom | ( | int | position ) |
Removes a point from the given position.
| void decCurve2D::ScalePointsBy | ( | float | scale ) |
Scales the Y coordinate of all curve points.
| void decCurve2D::SetDefaultCurve | ( | ) |
Clears the curve adding the points (0,0) and (1,1).
1.7.2