MonadicOperationModulate

com.phasmidsoftware.number.core.inner.MonadicOperationModulate
case class MonadicOperationModulate(min: Int, max: Int, inclusive: Boolean, angularBoundaryBehavior: Boolean) extends MonadicOperation

This class represents a monadic operation that modulates a numeric input into a specified range using modular arithmetic. It allows defining a flexible boundary behavior, which can either model standard numeric ranges or angular (circular) ranges, with the ability to make the range inclusive.

Value parameters

angularBoundaryBehavior

when true, treats the boundary as circular (e.g., for angles), otherwise treats it as standard numeric behavior

inclusive

if true, both min and max are valid; if false, max is excluded, unless boundaryBehavior specifies otherwise.

max

the upper bound of the modulation range

min

the lower bound of the modulation range

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def modulate[X](value: X, min: X, max: X, inclusive: Boolean, boundaryBehavior: BoundaryBehavior[X])(using Modulo[X]): X

Modulates a value into a specified range [min, max] using modular arithmetic. The result ensures the value falls within the inclusive range. Optionally supports circular ranges where min wraps to max.

Modulates a value into a specified range [min, max] using modular arithmetic. The result ensures the value falls within the inclusive range. Optionally supports circular ranges where min wraps to max.

Value parameters

inclusive

if true, both min and max are valid; if false, max is excluded, unless boundaryBehavior specifies otherwise.

max

the maximum of the range (inclusive according to inclusive parameter)

min

the minimum of the range (always inclusive)

value

the value to modulate

Attributes

Returns

the modulated value within the range [min, max]

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product

Concrete fields

Defines a set of functions for modulating a numeric input to a specified range, leveraging the modulate method. Each function within the tuple is wrapped in a Try for safe evaluation.

Defines a set of functions for modulating a numeric input to a specified range, leveraging the modulate method. Each function within the tuple is wrapped in a Try for safe evaluation.

The tuple contains:

  • A modulation function for numeric inputs matching the provided minimum and maximum bounds as integers.
  • A modulation function for numeric inputs with bounds converted to Rational.
  • Another modulation function for numeric inputs matching the provided integer bounds.

Attributes

val fuzz: Option[Int]

Relative precision, as used by Fuzziness.createFuzz.

Relative precision, as used by Fuzziness.createFuzz.

Attributes

val relativeFuzz: Double => Double

Function to yield the relative fuzz of the output Number, given the relative fuzz of the input Number.

Function to yield the relative fuzz of the output Number, given the relative fuzz of the input Number.

Attributes