Math¶
The rite.numeric.math submodule provides small, focused mathematical helpers such as clamp, sign, and power.
Math Module¶
Basic mathematical operations.
This submodule provides utilities for basic math operations like clamping, absolute value, sign, and power.
Examples¶
from rite.numeric.math import math_clamp, math_sign math_clamp(5, 0, 10) 5 math_sign(-5) -1
Modules¶
math_abs
¶
math_clamp
¶
Clamp Function¶
Clamp a value between minimum and maximum bounds.
Examples¶
from rite.numeric.math import math_clamp math_clamp(5, 0, 10) 5
Functions¶
math_clamp(value: float, minimum: float, maximum: float) -> float
¶
Clamp a value between minimum and maximum bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
Value to clamp. |
required |
minimum
|
float
|
Lower bound. |
required |
maximum
|
float
|
Upper bound. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Clamped value. |
Examples:
Notes
If minimum > maximum, behavior is undefined.
math_pow
¶
Power Function¶
Raise a number to a power.
Examples¶
from rite.numeric.math import math_pow math_pow(2, 3) 8.0
Functions¶
math_pow(base: float, exponent: float) -> float
¶
Raise a number to a power.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
float
|
Base number. |
required |
exponent
|
float
|
Exponent. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Result of base ** exponent. |
Examples:
Notes
Wrapper around ** operator for consistency.
options: show_root_heading: true show_source: false heading_level: 2