luxe: math
import "luxe: math" for MathUtility class with static math functions.
Math.add(..)
Section titled “Math.add(..)”Math.add(a : Vec, b : Vec) : unknownAdd two 3D vectors together componentwise, returning the result
Math.add2D(..)
Section titled “Math.add2D(..)”Math.add2D(a : Vec, b : Vec) : unknownAdd two vector2s together componentwise, returning the result
Math.add_to(..)
Section titled “Math.add_to(..)”Math.add_to(a : Vec, b : Vec) : unknownAdd two 3D vectors together componentwise, updating the first vector
Math.add2D_to(..)
Section titled “Math.add2D_to(..)”Math.add2D_to(a : Vec, b : Vec) : unknownAdd two 2D vectors together componentwise, updating the first vector
Math.sub(..)
Section titled “Math.sub(..)”Math.sub(a : Vec, b : Vec) : unknownSubtract two 3D vectors together componentwise, returning the result
Math.sub2D(..)
Section titled “Math.sub2D(..)”Math.sub2D(a : Vec, b : Vec) : unknownSubtract two 2D vectors together componentwise, returning the result
Math.sub_to(..)
Section titled “Math.sub_to(..)”Math.sub_to(a : Vec, b : Vec) : unknownSubtract two 3D vectors together componentwise, updating the first vector
Math.sub2D_to(..)
Section titled “Math.sub2D_to(..)”Math.sub2D_to(a : Vec, b : Vec) : unknownSubtract two 2D vectors together componentwise, updating the first vector
Math.mults(..)
Section titled “Math.mults(..)”Math.mults(a : Vec, b : Num) : unknownMultiply a 3D vector by a scalar, returning the result
Math.mult(..)
Section titled “Math.mult(..)”Math.mult(a : Vec, b : Vec) : unknownMultiply two 3D vectors together componentwise, returning the result
Math.mult2D(..)
Section titled “Math.mult2D(..)”Math.mult2D(a : Vec, b : Vec) : unknownMultiply two 2D vectors together componentwise, returning the result
Math.mult_to(..)
Section titled “Math.mult_to(..)”Math.mult_to(a : Vec, b : Vec) : unknownMultiply two 3D vectors together componentwise, updating the first vector
Math.mults_to(..)
Section titled “Math.mults_to(..)”Math.mults_to(a : Vec, b : Num) : unknownMultiply a 3D vector by a scalar, updating the vector
Math.mult2D_to(..)
Section titled “Math.mult2D_to(..)”Math.mult2D_to(a : Vec, b : Vec) : unknownMultiply two 2D vectors together componentwise, updating the first vector
Math.scale(..)
Section titled “Math.scale(..)”Math.scale(a : Vec, s : Num) : unknownMultiply a 3D vector by a scalar, returning the result
Math.scale2D(..)
Section titled “Math.scale2D(..)”Math.scale2D(a : Vec, s : Num) : unknownMultiply a 2D vector by a scalar, returning the result
Math.scale_to(..)
Section titled “Math.scale_to(..)”Math.scale_to(a : Vec, s : Num) : unknownMultiply a 3D vector by a scalar, updating the vector
Math.scale2D_to(..)
Section titled “Math.scale2D_to(..)”Math.scale2D_to(a : Vec, s : Num) : unknownMultiply a 2D vector by a scalar, updating the vector
Math.divide(..)
Section titled “Math.divide(..)”Math.divide(a : Vec, b : Vec) : unknownDivide a 3D vector by another, returning the result
Math.divide_to(..)
Section titled “Math.divide_to(..)”Math.divide_to(vec : Vec, other : Vec) : unknownDivide a 3D vector by another, updating the vector
Math.divide2D(..)
Section titled “Math.divide2D(..)”Math.divide2D(a : Vec, b : Vec) : unknownDivide a 2D vector by another, returning the result
Math.divide2D_to(..)
Section titled “Math.divide2D_to(..)”Math.divide2D_to(vec : Vec, other : Vec) : unknownDivide a 2D vector by another, updating the vector
Math.div(..)
Section titled “Math.div(..)”Math.div(a : Vec, s : Num) : unknownDivide a 3D vector by a scalar, returning the result
Math.div2D(..)
Section titled “Math.div2D(..)”Math.div2D(a : Vec, s : Num) : unknownDivide a 2D vector by a scalar, returning the result
Math.div_to(..)
Section titled “Math.div_to(..)”Math.div_to(a : Vec, s : Num) : unknownDivide a 3D vector by a scalar, updating the vector
Math.div2D_to(..)
Section titled “Math.div2D_to(..)”Math.div2D_to(a : Vec, s : Num) : unknownDivide a 2D vector by a scalar, updating the vector
Math.equal(..)
Section titled “Math.equal(..)”Math.equal(a : Vec, b : Vec) : BoolChecks if two vectors are equal. Vectors of different dimensions (e.g. 2D and 3D) are considered unequal
Math.length(..)
Section titled “Math.length(..)”Math.length(x : Num, y : Num) : NumLength of a 2d vector.
Math.length(…)
Section titled “Math.length(…)”Math.length(x : Num, y : Num, z : Num) : NumLength of a 3d vector.
Math.length(.)
Section titled “Math.length(.)”Math.length(vec : Vec) : NumLength of a 3d vector.
Math.length2D(.)
Section titled “Math.length2D(.)”Math.length2D(vec : Vec) : NumLength of a 2d vector.
Math.length_sq(..)
Section titled “Math.length_sq(..)”Math.length_sq(x : Num, y : Num) : NumSquared length of a 2d vector (slightly cheaper than length).
Math.length_sq(…)
Section titled “Math.length_sq(…)”Math.length_sq(x : Num, y : Num, z : Num) : NumSquared length of a 3d vector (slightly cheaper than length).
Math.length_sq(.)
Section titled “Math.length_sq(.)”Math.length_sq(vec : Vec) : NumSquared length of a 3d vector.
Math.length_sq2D(.)
Section titled “Math.length_sq2D(.)”Math.length_sq2D(vec : Vec) : NumSquared length of a 2d vector.
Math.dot(…)
Section titled “Math.dot(…)”Math.dot(x : Num, y : Num, z : Num, other_x : Num, other_y : Num, other_z : Num) : NumDot product (or scalar product) of two 3d vectors.
Math.dot(…)
Section titled “Math.dot(…)”Math.dot(x : Num, y : Num, other_x : Num, other_y : Num) : NumDot product (or scalar product) of two 2d vectors.
Math.dot(..)
Section titled “Math.dot(..)”Math.dot(vec : Vec, other : Vec) : NumDot product (or scalar product) of two 3d vectors.
Math.dot2D(..)
Section titled “Math.dot2D(..)”Math.dot2D(vec : Vec, other : Vec) : NumDot product (or scalar product) of two 2d vectors.
Math.cross(..)
Section titled “Math.cross(..)”Math.cross(a : Vec, b : Vec) : VecCross product of two 3d vectors. Result will always be orthogonal to both input vectors (and [0, 0, 0] if the arguments are parallel)
Math.angle(..)
Section titled “Math.angle(..)”Math.angle(from : Vec, to : Vec) : NumUnsigned angle between two 3d vectors.
Math.angle(…)
Section titled “Math.angle(…)”Math.angle(v1 : Vec, v2 : Vec, up : Vec) : NumSigned angle between two 3d vectors.
Math.angle2D(..)
Section titled “Math.angle2D(..)”Math.angle2D(from : Vec, to : Vec) : NumSigned angle between two 2d vectors.
Math.angle2D(…)
Section titled “Math.angle2D(…)”Math.angle2D(from_x : Num, from_y : Num, to_x : Num, to_y : Num) : NumSigned angle between two 2d vectors.
Math.normalize2D(.)
Section titled “Math.normalize2D(.)”Math.normalize2D(vec : Vec) : NoneNormalize 2d vector. Changes input vector and doesnt return anything. 0 length vectors remain untouched.
Math.normalized(.)
Section titled “Math.normalized(.)”Math.normalized(vec : Vec) : NoneNormalize 3d vector. Returns the result.
Math.normalized2D(.)
Section titled “Math.normalized2D(.)”Math.normalized2D(vec : Vec) : NoneNormalize 2d vector. Returns the result.
Math.normalize(.)
Section titled “Math.normalize(.)”Math.normalize(vec : Vec) : NoneNormalize 3d vector. Changes input vector and doesnt return anything. 0 length vectors remain untouched.
Math.dist(…)
Section titled “Math.dist(…)”Math.dist(x : Num, y : Num, z : Num, other_x : Num, other_y : Num, other_z : Num) : NumDistance between two 3d vectors.
Math.dist(..)
Section titled “Math.dist(..)”Math.dist(vec : Vec, other : Vec) : NumDistance between two 3d vectors.
Math.dist2D(..)
Section titled “Math.dist2D(..)”Math.dist2D(vec : Vec, other : Vec) : NumDistance between two 2d vectors.
Math.dist2D(…)
Section titled “Math.dist2D(…)”Math.dist2D(x : Num, y : Num, other_x : Num, other_y : Num) : NumDistance between two 2d vectors.
Math.dir2D(..)
Section titled “Math.dir2D(..)”Math.dir2D(pos : Vec, target : Vec) : VecDirectional vector (length 1 unless the arguments are the same) between two 2d vectors.
Math.dir(..)
Section titled “Math.dir(..)”Math.dir(pos : Vec, target : Vec) : VecDirectional vector (length 1 unless the arguments are the same) between two 3d vectors.
Math.rotate(…)
Section titled “Math.rotate(…)”Math.rotate(vec : Vec, axis : Vec, angle : Num) : VecRotate a 3d vector around the given axis by angle degrees
Math.rotate_by_quat(..)
Section titled “Math.rotate_by_quat(..)”Math.rotate_by_quat(vec : Vec, quat : Float4) : VecRotate a 3d vector using the given quaternion
Math.quat_from_euler(.)
Section titled “Math.quat_from_euler(.)”Math.quat_from_euler(vec : Vec) : Float4Create a quaternion from float3 euler (radians)
Math.rotate(…)
Section titled “Math.rotate(…)”Math.rotate(vec : Vec, ox : Num, oy : Num, angle : Num) : NoneRotate 2d vector around another 2d vector. This rotates the input vector and doesnt return anything.
Math.ray_intersect_plane(…)
Section titled “Math.ray_intersect_plane(…)”Math.ray_intersect_plane(plane_x : Num, plane_y : Num, plane_z : Num, normal_x : Num, normal_y : Num, normal_z : Num, ray_x : Num, ray_y : Num, ray_z : Num, ray_dir_x : Num, ray_dir_y : Num, ray_dir_z : Num) : VecIntersection point between an infinitely long ray and a infinitely big plane. Returns
nullif parallel.
Math.closest_point_on_plane(…)
Section titled “Math.closest_point_on_plane(…)”Math.closest_point_on_plane(plane_x : Num, plane_y : Num, plane_z : Num, normal_x : Num, normal_y : Num, normal_z : Num, point_x : Num, point_y : Num, point_z : Num) : VecClosest point on an infinite plane to a point.
Math.closest_point_on_line(…)
Section titled “Math.closest_point_on_line(…)”Math.closest_point_on_line(line_x : Num, line_y : Num, line_z : Num, line_end_x : Num, line_end_y : Num, line_end_z : Num, point_x : Num, point_y : Num, point_z : Num) : VecClosest point on an infinite line to a point. The progress from line start to line end in 4th component of return value. Line is constructed by 2 points on the line, but the closest point can also be before the start of after the end (in that case the 4th component of the return value wont be in the 0-1 range).
Math.closest_point_on_line(…)
Section titled “Math.closest_point_on_line(…)”Math.closest_point_on_line(line : Vec, line_end : Vec, point : Vec) : VecClosest point on an infinite line to a point. The progress from line start to line end in 4th component of return value. Line is constructed by 2 points on the line, but the closest point can also be before the start of after the end (in that case the 4th component of the return value wont be in the 0-1 range).
Math.in_rect(…)
Section titled “Math.in_rect(…)”Math.in_rect(x : Num, y : Num, rx : Num, ry : Num, rw : Num, rh : Num) : BoolChecks if a 2d point is inside a rectangle. Only works for positive rectangle sizes.
Math.in_volume(…)
Section titled “Math.in_volume(…)”Math.in_volume(pos : Vec, origin : Vec, extents : Vec) : unknownChecks if point is inside the volume at origin with extents
Math.wrap(..)
Section titled “Math.wrap(..)”Math.wrap(value : Num, modulus : Num) : Numno docs found
Math.overlaps(…)
Section titled “Math.overlaps(…)”Math.overlaps(x0 : Num, y0 : Num, w0 : Num, h0 : Num, x1 : Num, y1 : Num, w1 : Num, h1 : Num) : BoolChecks if two rectangles overlap. Only works for positive rectangle sizes.
Math.sign(.)
Section titled “Math.sign(.)”Math.sign(x : Num) : NumThe sign of the number, expressed as a -1, 1 or 0, for negative and positive numbers, and zero.
Math.sign0(.)
Section titled “Math.sign0(.)”Math.sign0(x : Num) : NumThe sign of the number, expressed as a -1 0r 1, for negative and positive numbers, zero is positive.
Math.atan2(..)
Section titled “Math.atan2(..)”Math.atan2(y : Num, x : Num) : NumThe arc tangent of
ywhen divided byx, using the signs of the two numbers to determine the quadrant of the result. (equivalient toy.atan(x))
Math.degrees(.)
Section titled “Math.degrees(.)”Math.degrees(radians : Num) : NumConvert radians (0…2*PI) to degree (0…360).
Math.radians(.)
Section titled “Math.radians(.)”Math.radians(degrees : Num) : NumConvert degree (0…360) to radians (0…2*PI).
Math.clamp(…)
Section titled “Math.clamp(…)”Math.clamp(value : Num, a : Num, b : Num) : NumClamp
valuebetweenaandb(result will never be smaller than a or bigger than b). Equivalent tovalue.clamp(a, b).
Math.min(..)
Section titled “Math.min(..)”Math.min(a : Num, b : Num) : NumThe smaller of two numbers. Eqivalent to
a.min(b).
Math.max(..)
Section titled “Math.max(..)”Math.max(a : Num, b : Num) : NumThe larger of two numbers. Eqivalent to
a.max(b).
Math.floor_around_zero(.)
Section titled “Math.floor_around_zero(.)”Math.floor_around_zero(a : Num) : NumRound towards zero. (floor when positive, ceil when negative)
Math.ceil_around_zero(.)
Section titled “Math.ceil_around_zero(.)”Math.ceil_around_zero(a : Num) : NumRound away from zero. (ceil when positive, floor when negative)
Math.fixed(.)
Section titled “Math.fixed(.)”Math.fixed(value : Num) : NumRound number to 3 digits after comma precision.
Math.fixed(..)
Section titled “Math.fixed(..)”Math.fixed(value : Num, precision : Num) : NumRound number to
precisiondigits after comma precision.
Math.angle_delta(..)
Section titled “Math.angle_delta(..)”Math.angle_delta(from : Num, to : Num) : NumSigned difference between two (degree) angles. Always in -180…180 range.
Math.lerp2D(…)
Section titled “Math.lerp2D(…)”Math.lerp2D(a : Vec, b : Vec, t : Num) : VecLinearly interpolate between two vectors. Returns
awhentis0andbwhentis1, with values inbetween interpolating inbetween. Iftis outside 0-1 range, the output will be extrapolated.
Math.lerp3D(…)
Section titled “Math.lerp3D(…)”Math.lerp3D(a : Vec, b : Vec, t : Num) : VecLinearly interpolate between two vectors. Returns
awhentis0andbwhentis1, with values inbetween interpolating inbetween. Iftis outside 0-1 range, the output will be extrapolated.
Math.smooth_t(..)
Section titled “Math.smooth_t(..)”Math.smooth_t(t : Num, smoothness : Num) : NumGet a smooth time t for lerping, based on a smoothness value. e.g t = smooth_t(delta, 1.25). exponential decay
Math.smoother_t(..)
Section titled “Math.smoother_t(..)”Math.smoother_t(t : Num, smoothness : Num) : NumGet a smooth time t for lerping, based on a smoothness value. e.g t = smoother_t(delta, 1.25). s curve like shape
Math.lerp(…)
Section titled “Math.lerp(…)”Math.lerp(a : Num, b : Num, t : Num) : NumLinearly interpolate between two numbers. Returns
awhentis0andbwhentis1, with values inbetween interpolating inbetween. Iftis outside 0-1 range, the output will be extrapolated.
Math.lerp_angle(…)
Section titled “Math.lerp_angle(…)”Math.lerp_angle(a : Num, b : Num, t : Num) : NumInterpolates between angles. Always in 0…360 range.
Math.weighted_avg(…)
Section titled “Math.weighted_avg(…)”Math.weighted_avg(value : Num, target : Num, slowness : Num) : unknownno docs found
Math.within_range(…)
Section titled “Math.within_range(…)”Math.within_range(value : Num, start_range : Num, end_range : Num) : unknownChecks whether
valueis inbetweenstart_rangeandend_range(inclusive).
Math.approx(..)
Section titled “Math.approx(..)”Math.approx(one : Num, other : Num) : BoolChecks whether two values are approximately the same (with a max difference of 0.001).
Math.approx(…)
Section titled “Math.approx(…)”Math.approx(one : Num, other : Num, epsilon : Num) : BoolChecks whether two values are approximately the same (with a max difference of
epsilon).
Math.wrap_angle(.)
Section titled “Math.wrap_angle(.)”Math.wrap_angle(degrees : Num) : NumBring angle into 0…360 degree space.
Math.wrap_angle(…)
Section titled “Math.wrap_angle(…)”Math.wrap_angle(degrees : Num, lower : Num, upper : Num) : NumBring angle into lower…upper degree space.
Math.wrap_radians(…)
Section titled “Math.wrap_radians(…)”Math.wrap_radians(radians : Num, lower : Num, upper : Num) : Numno docs found
Math.nearest_power_of_two(.)
Section titled “Math.nearest_power_of_two(.)”Math.nearest_power_of_two(value : Num) : Numno docs found
Math.map_linear(…)
Section titled “Math.map_linear(…)”Math.map_linear(value : Num, a1 : Num, a2 : Num, b1 : Num, b2 : Num) : NumRemap value from
a1...a2space tob1...b2space (unclamped).
Math.smoothstep(…)
Section titled “Math.smoothstep(…)”Math.smoothstep(x : Num, min : Num, max : Num) : NumSmoothed inverse lerp using cubic hermite interpolation. Output is clamped between 0 and 1.
Math.smootherstep(…)
Section titled “Math.smootherstep(…)”Math.smootherstep(x : Num, min : Num, max : Num) : NumAlternate smooth inverse interpolation with derivative of 0 at min and max points. Output is clamped between 0 and 1.
Math.smoothstepx(…)
Section titled “Math.smoothstepx(…)”Math.smoothstepx(x : Num, round : Num, steep : Num) : unknownno docs found
Math.random_point_in_unit_circle(.)
Section titled “Math.random_point_in_unit_circle(.)”Math.random_point_in_unit_circle(rng : Random) : NumRandom 2d point in circle of radius 1. Has uniform distribution.
Math.slerp(…)
Section titled “Math.slerp(…)”Math.slerp(a : Quat, b : Quat, t : Num) : unknownno docs found