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.
To add control points to this curve, call the
addControlPoint(double, double)
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
get(double, double, double)
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.
- Source Modules
- This module requires one source module.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A control point for defining splines. -
Field Summary
Fields inherited from class org.spongepowered.noise.module.NoiseModule
sourceModule
-
Constructor Summary
ConstructorDescriptionCurve()
Curve
(NoiseModule source) Create a new Curve module with the source modules pre-configured. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addControlPoint
(double inputValue, double outputValue) Adds a control point to the curve.void
Delete all control points on the curve.Get a copy of the array holding all control points.double
get
(double x, double y, double z) Generates an output value given the coordinates of the specified input value.Methods inherited from class org.spongepowered.noise.module.NoiseModule
setSourceModule, sourceModule, sourceModuleCount
-
Constructor Details
-
Curve
public Curve() -
Curve
Create a new Curve module with the source modules pre-configured.- Parameters:
source
- the input module
-
-
Method Details
-
addControlPoint
public void addControlPoint(double inputValue, double outputValue) Adds a control point to the curve.No two control points amy have the same input value.
It does not matter which order these points are added in.
- Parameters:
inputValue
- the input value stored in the control pointoutputValue
- the output value stored in the control point- Throws:
IllegalArgumentException
- if more than one control point has the same input value
-
controlPoints
Get a copy of the array holding all control points.- Returns:
- a copy of the array of control points
-
clearControlPoints
public void clearControlPoints()Delete all control points on the curve. -
get
public double get(double x, double y, double z) Description copied from class:NoiseModule
Generates an output value given the coordinates of the specified input value.All source modules required by this module must have been connected with the
NoiseModule.setSourceModule(int, NoiseModule)
method. If these source modules are not connected, this method will throw aNoModuleException
.To determine the number of source modules required by this noise module, call the
NoiseModule.sourceModuleCount()
method.- Specified by:
get
in classNoiseModule
- Parameters:
x
- thex
coordinate of the input valuey
- they
coordinate of the input valuez
- thez
coordinate of the input value- Returns:
- the output value
-