Class Curve


  • public class Curve
    extends Module
    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 getValue(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 Detail

      • Curve

        public Curve()
      • Curve

        public Curve​(Module source)
        Create a new Curve module with the source modules pre-configured.
        Parameters:
        source - the input module
    • Method Detail

      • 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
      • getControlPoints

        public Curve.ControlPoint[] getControlPoints()
        Get a copy of the array holding all control points.
        Returns:
        a copy of the array of control points
      • clearAllControlPoints

        public void clearAllControlPoints()
        Delete all control points on the curve.
      • getValue

        public double getValue​(double x,
                               double y,
                               double z)
        Description copied from class: Module
        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 Module.setSourceModule(int, Module) 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 Module.getSourceModuleCount() method.

        Specified by:
        getValue in class Module
        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