Studio Yotsuba
Back to Node List

Math Func

math_func

Applies a common single-input math function to a number

Reviewed
Guide available

Input Ports

NameTypeDescription
Input
input
Number
Required
Input value

Output Ports

NameTypeDescription
Value
value
Number
Function result

Parameters

NameTypeDefaultRangeDescription / Options
Function
func
Enum
Abs—

Choose which calculation to apply

  • AbsAbs
    Absolute value
  • FloorFloor
    Round down toward negative infinity
  • CeilCeil
    Round up
  • RoundRound
    Round to nearest
  • FractFract
    Fractional part
  • SqrtSqrt
    Square root
  • SinSin
    Sine
  • CosCos
    Cosine
  • TanTan
    Tangent
  • ExpExp
    Exponential (e^x)
  • LogLog
    Natural logarithm
  • NegateNegate
    Negate
  • SignSign
    Sign (-1 / 0 / 1)

Overview

Applies one function—such as absolute value, rounding, or a trigonometric function—to one number. Together with the two-input math_op, it is another fundamental building block for numeric wiring.

Usage tips

  • Rounding functions are especially useful in pixel art. Converting coordinates or indices to integers with Floor / Round produces motion that snaps to pixels. To turn a smooth waveform into stepped motion, combine Floor with multiplication by the number of steps.
  • Abs folds a round trip into one direction: a waveform from -1 to 1 becomes two peaks from 0 to 1.
  • Sin / Cos expect radians. To work in degrees, multiply by 0.01745 (π/180) in a preceding math_op(Multiply).

Related nodes

  • math_op — two-input operations
  • expression_float — write an expression such as floor(x*4)/4 in one node
  • remap — convert ranges, often before or after rounding

Functions

  • Abs
    • Absolute value. Converts a negative value to positive. Example: -3 -> 3
  • Floor
    • Rounds down toward negative infinity. Example: -1.2 -> -2
  • Ceil
    • Rounds up. Example: 3.2 -> 4
  • Round
    • Rounds to the nearest integer. Example: 3.5 -> 4
  • Fract
    • Extracts only the fractional part. Example: 3.8 -> 0.8
  • Sqrt
    • Square root. Example: 9 -> 3
  • Sin / Cos / Tan
    • Trigonometric functions calculated in radians, not degrees.
  • Exp
    • Calculates e^x, or e (approximately 2.718) to the power of x. Example: 3 -> 20.085...
  • Log
    • Natural logarithm ln(x), using e as the base.
  • Negate
    • Reverses the sign, swapping positive and negative. Example: 3 -> -3
  • Sign
    • Tests the sign. Returns -1.0 for a negative value, 0.0 for zero, and 1.0 for a positive value.

Notes

  • Sqrt accepts only inputs greater than or equal to 0.
  • Log accepts only inputs greater than 0.
  • The value currently returned at runtime is Float, while the port contract is Number.

Examples

  • Use Abs to make values from Noise Wave positive.
  • Insert Floor before Remap to create steps.
  • Build periodic motion with Sin / Cos.
  • Use Sign to switch direction depending on whether a value is positive or negative.
Back to Node List