CS::Math::Noise::Module::Curve Class Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes
CS::Math::Noise::Module::Curve Class Reference
Modifier Modules

Noise module that maps the output value from a source module onto an arbitrary function curve. More...

`#include <cstool/noise/module/curve.h>`

Inheritance diagram for CS::Math::Noise::Module::Curve:

List of all members.

## Public Member Functions
void | AddControlPoint (double inputValue, double outputValue)
| Adds a control point to the curve.
void | ClearAllControlPoints ()
| Deletes all the control points on the curve.
| Curve ()
| Constructor.
const ControlPoint * | GetControlPointArray () const
| Returns a pointer to the array of control points on the curve.
int | GetControlPointCount () const
| Returns the number of control points on the curve.
virtual int | GetSourceModuleCount () const
| Returns the number of source modules required by this noise module.
virtual double | GetValue (double x, double y, double z) const
| Generates an output value given the coordinates of the specified input value.
| ~Curve ()
| Destructor.
## Protected Member Functions
int | FindInsertionPos (double inputValue)
| Determines the array index in which to insert the control point into the internal control point array.
void | InsertAtPos (int insertionPos, double inputValue, double outputValue)
| Inserts the control point at the specified position in the internal control point array.
## Protected Attributes
int | m_controlPointCount
| Number of control points on the curve.
ControlPoint * | m_pControlPoints
| Array that stores the control points.

## Detailed Description

Noise module that maps the output value from a source module onto an arbitrary function curve.

This noise module maps the output value from the source module onto an application-defined curve. This curve is defined by a number of control points; each control point has an input value that maps to an output value. Refer to the following illustration:

To add the control points to this curve, call the AddControlPoint() method.

Since this curve is a cubic spline, an application must add a minimum of four control points to the curve. If this is not done, the GetValue() method fails. Each control point can have any input and output value, although no two control points can have the same input value. There is no limit to the number of control points that can be added to the curve.

This noise module requires one source module.

Definition at line 80 of file curve.h.

## Constructor & Destructor Documentation

CS::Math::Noise::Module::Curve::Curve | ( |  | ) |

Constructor.

CS::Math::Noise::Module::Curve::~Curve | ( |  | ) |

Destructor.

## Member Function Documentation

void CS::Math::Noise::Module::Curve::AddControlPoint | ( | double | inputValue,
|  | double | outputValue
| ) |  |

Adds a control point to the curve.

Parameters:

  inputValue | The input value stored in the control point.
  outputValue | The output value stored in the control point.

Precondition:
  No two control points have the same input value.

Exceptions:

  CS::Math::Noise::ExceptionInvalidParam | An invalid parameter was specified; see the preconditions for more information.

It does not matter which order these points are added.

void CS::Math::Noise::Module::Curve::ClearAllControlPoints | ( |  | ) |

Deletes all the control points on the curve.

Postcondition:
  All points on the curve are deleted.

int CS::Math::Noise::Module::Curve::FindInsertionPos | ( | double | inputValue | ) | `[protected]`

Determines the array index in which to insert the control point into the internal control point array.

Parameters:

  inputValue | The input value of the control point.

Returns:
  The array index in which to insert the control point.

Precondition:
  No two control points have the same input value.

Exceptions:

  CS::Math::Noise::ExceptionInvalidParam | An invalid parameter was specified; see the preconditions for more information.

By inserting the control point at the returned array index, this class ensures that the control point array is sorted by input value. The code that maps a value onto the curve requires a sorted control point array.

const ControlPoint* CS::Math::Noise::Module::Curve::GetControlPointArray | ( |  | ) | const`[inline]`

Returns a pointer to the array of control points on the curve.

Returns:
  A pointer to the array of control points.

Before calling this method, call GetControlPointCount() to determine the number of control points in this array.

It is recommended that an application does not store this pointer for later use since the pointer to the array may change if the application calls another method of this object.

Definition at line 119 of file curve.h.

int CS::Math::Noise::Module::Curve::GetControlPointCount | ( |  | ) | const`[inline]`

Returns the number of control points on the curve.

Returns:
  The number of control points on the curve.

Definition at line 127 of file curve.h.

virtual int CS::Math::Noise::Module::Curve::GetSourceModuleCount | ( |  | ) | const`[inline, virtual]`

Returns the number of source modules required by this noise module.

Returns:
  The number of source modules required by this noise module.

Implements CS::Math::Noise::Module::Module.

Definition at line 132 of file curve.h.

virtual double CS::Math::Noise::Module::Curve::GetValue | ( | double | x,
|  | double | y,
|  | double | z
| ) |  | const`[virtual]`

Generates an output value given the coordinates of the specified input value.

Parameters:

  x | The x coordinate of the input value.
  y | The y coordinate of the input value.
  z | The z coordinate of the input value.

Returns:
  The output value.

Precondition:
  All source modules required by this noise module have been passed to the SetSourceModule() method.

Before an application can call this method, it must first connect all required source modules via the SetSourceModule() method. If these source modules are not connected to this noise module, this method raises a debug assertion.

To determine the number of source modules required by this noise module, call the GetSourceModuleCount() method.

Implements CS::Math::Noise::Module::Module.

void CS::Math::Noise::Module::Curve::InsertAtPos | ( | int | insertionPos,
|  | double | inputValue,
|  | double | outputValue
| ) |  | `[protected]`

Inserts the control point at the specified position in the internal control point array.

Parameters:

  insertionPos | The zero-based array position in which to insert the control point.
  inputValue | The input value stored in the control point.
  outputValue | The output value stored in the control point.

To make room for this new control point, this method reallocates the control point array and shifts all control points occurring after the insertion position up by one.

Because the curve mapping algorithm used by this noise module requires that all control points in the array must be sorted by input value, the new control point should be inserted at the position in which the order is still preserved.

## Member Data Documentation

int CS::Math::Noise::Module::Curve::m_controlPointCount`[protected]`

Number of control points on the curve.

Definition at line 179 of file curve.h.

ControlPoint* CS::Math::Noise::Module::Curve::m_pControlPoints`[protected]`

Array that stores the control points.

Definition at line 182 of file curve.h.

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

- cstool/noise/module/curve.h