Math - JakeTurner616/pygame-lua-bindings GitHub Wiki
clamp(value, min_val, max_val)
Clamps a numeric value so that it's no lower than min_val, and no higher than max_val.
Parameters:
value
: The value to clamp.min_val
: The minimum value.max_val
: The maximum value.
Returns: The clamped value.
Maps to:
max
: This function is used to find the maximum value between two numbers.min
: This function is used to find the minimum value between two numbers.
lerp(a, b, weight)
Linearly interpolates between a and b by weight.
Parameters:
a
: The start value.b
: The end value.weight
: The weight of interpolation.
Returns: The interpolated value.
Maps to:
- Arithmetic operations: This function performs arithmetic operations to calculate the linear interpolation.
Vector2(x, y=None)
Create a 2D vector.
Parameters:
x
: The x component of the vector.y
: The y component of the vector (optional).
Returns: A 2D vector object.
Maps to:
pygame.math.Vector2
: This function creates a 2D vector.
Vector3(x, y, z)
Create a 3D vector.
Parameters:
x
: The x component of the vector.y
: The y component of the vector.z
: The z component of the vector.
Returns: A 3D vector object.
Maps to:
pygame.math.Vector3
: This function creates a 3D vector.
get_pi()
Return the value of pi.
Parameters: None.
Returns: The value of pi.
Maps to:
pi
: The mathematical constant pi.
get_sin(x)
Return the sine of x (measured in radians).
Parameters:
x
: Angle in radians.
Returns: The sine of x.
Maps to:
sin(x)
: Sine function in Python's math module.
get_cos(x)
Return the cosine of x (measured in radians).
Parameters:
x
: Angle in radians.
Returns: The cosine of x.
Maps to:
cos(x)
: Cosine function in Python's math module.
get_tan(x)
Return the tangent of x (measured in radians).
Parameters:
x
: Angle in radians.
Returns: The tangent of x.
Maps to:
tan(x)
: Tangent function in Python's math module.
get_asin(x)
Return the arc sine of x, in radians.
Parameters:
x
: Value whose arc sine is to be calculated.
Returns: The arc sine of x.
Maps to:
asin(x)
: Arc sine function in Python's math module.
get_acos(x)
Return the arc cosine of x, in radians.
Parameters:
x
: Value whose arc cosine is to be calculated.
Returns: The arc cosine of x.
Maps to:
acos(x)
: Arc cosine function in Python's math module.
get_atan(x)
Return the arc tangent of x, in radians.
Parameters:
x
: Value whose arc tangent is to be calculated.
Returns: The arc tangent of x.
Maps to:
atan(x)
: Arc tangent function in Python's math module.
get_atan2(y, x)
Return atan(y / x), in radians. The result is between -pi and pi.
Parameters:
y
: Numerator.x
: Denominator.
Returns: The arc tangent of y / x.
Maps to:
atan2(y, x)
: Two-argument arc tangent function in Python's math module.
get_exp(x)
Return e raised to the power of x.
Parameters:
x
: Exponent.
Returns: The value of e raised to the power of x.
Maps to:
exp(x)
: Exponential function in Python's math module.
get_log(x, base=None)
Return the logarithm of x to the given base. If the base is not specified, returns the natural logarithm (base e) of x.
Parameters:
x
: Number.base
: Base of the logarithm. If not specified, defaults to natural logarithm.
Returns: The logarithm of x to the given base.
Maps to:
log(x, base)
: Logarithm function in Python's math module.
get_log10(x)
Return the base-10 logarithm of x.
Parameters:
x
: Number.
Returns: The base-10 logarithm of x.
Maps to:
log10(x)
: Base-10 logarithm function in Python's math module.
get_pow(x, y)
Return x raised to the power of y.
Parameters:
x
: Base.y
: Exponent.
Returns: x raised to the power of y.
Maps to:
pow(x, y)
: Power function in Python's math module.
get_sqrt(x)
Return the square root of x.
Parameters:
x
: Number.
Returns: The square root of x.
Maps to:
sqrt(x)
: Square root function in Python's math module.
get_ceil(x)
Return the ceiling of x as an Integral.
Parameters:
x
: Number.
Returns: The smallest integer greater than or equal to x.
Maps to:
ceil(x)
: Ceiling function in Python's math module.
get_floor(x)
Return the floor of x as an Integral.
Parameters:
x
: Number.
Returns: The largest integer less than or equal to x.
Maps to:
floor(x)
: Floor function in Python's math module.
get_fabs(x)
Return the absolute value of x.
Parameters:
x
: Number.
Returns: The absolute value of x.
Maps to:
fabs(x)
: Absolute value function in Python's math module.