java.lang.Object
org.spongepowered.noise.module.NoiseModule
org.spongepowered.noise.module.modifier.Curve

public class Curve extends NoiseModule
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.

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.
  • Constructor Details

    • Curve

      public Curve()
    • Curve

      public Curve(NoiseModule source)
      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 point
      outputValue - the output value stored in the control point
      Throws:
      IllegalArgumentException - if more than one control point has the same input value
    • controlPoints

      public Curve.ControlPoint[] 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 a NoModuleException.

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

      Specified by:
      get in class NoiseModule
      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