Class Clamp


  • public class Clamp
    extends Module
    Noise module that clamps the output value from a source module to a range of values.

    The range of values in which to clamp the output value is called the clamping range.

    If the output value from the source module is less than the lower bound of the clamping range, this noise module clamps that value to the lower bound. If the output value from the source module is greater than the upper bound of the clamping range, this noise module clamps that value to the upper bound.

    To specify the upper and lower bounds of the clamping range, call the setLowerBound(double) and setUpperBound(double) methods.

    Source Modules
    This module requires one source module.
    • Field Detail

      • DEFAULT_LOWER_BOUND

        public static final double DEFAULT_LOWER_BOUND
        Default lower bound of the clamping range for the Clamp noise module.
        See Also:
        Constant Field Values
      • DEFAULT_UPPER_BOUND

        public static final double DEFAULT_UPPER_BOUND
        Default upper bound of the clamping range of the Clamp noise module.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Clamp

        public Clamp()
      • Clamp

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

      • getLowerBound

        public double getLowerBound()
        Get the lower bound of the clamping range.

        If the output value from the source module is less than the lower bound of the clamping range, this noise module clamps that value to the lower bound.

        Returns:
        the lower bound
      • setLowerBound

        public void setLowerBound​(double lowerBound)
        Set the lower bound of the clamping range.

        The lower bound must be less than or equal to the upper bound.

        Parameters:
        lowerBound - the lower bound
      • getUpperBound

        public double getUpperBound()
        Get the upper bound of the clamping range.

        If the output value from the source module is greater than the upper bound of the clamping range, this noise module clamps that value to the upper bound.

        Returns:
        the upper bound
      • setUpperBound

        public void setUpperBound​(double upperBound)
        Set the upper bound of the clamping range.

        The upper bound must be greater than or equal to the lower bound.

        Parameters:
        upperBound - the upper bound
      • 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