Math
A module which contains math methods that are frequently used in minigames.
local Math = require(ReplicatedStorage.SharedModules.Utils.Math)Methods
AngleBetweenVec3_Radians
Returns the angle in radians between two Vector3s.
Math.AngleBetweenVec3_Radians(vecA: Vector3, vecB: Vector3): numberAxisToCF
Generally useless for minigames.
Uncompresses a Vector3 provided by Math.CFToAxis(...) into a rotation CFrame.
Math.AxisToCF(axis: Vector3): CFrameCFCLerp
Linear interpolation between two CFrames with alpha clamped to [0, 1].
Math.CFCLerp(start: CFrame, goal: CFrame, alpha: number): CFrameTIP
Redundant - Please use CFrame:Lerp(..., math.clamp(...)) instead.
CFToAxis
Generally useless for minigames.
Compresses a CFrame's rotation into a Vector3 by multiplying its unit Vector3 axis by its rotation angle in radians. Decompressed with Math.AxisToCF(...).
Math.CFToAxis(cf: CFrame): Vector3CLerp
Linear interpolation between two numbers with alpha clamped to [0, 1].
Math.CLerp(start: number, goal: number, alpha: number): numberTIP
Redundant - Please use math.map(math.clamp(...), ...) instead.
DegreeCLerp
Linear interpolation between angles in degrees with alpha clamped to [0, 1].
Math.DegreeCLerp(start: number, goal: number, alpha: number): numberDistanceXZ
Returns the XZ distance of two Vector3s.
Math.DistanceXZ(vec1: Vector3, vec2: Vector3): numberGetVecXZ
Returns the Vector3 without the Y component.
Math.GetVecXZ(vec: Vector3): Vector3GetVecXZUnit
Returns the unit vector of a Vector3 while ignoring the Y component.
Math.GetVecXZUnit(vec: Vector3): Vector3WARNING
Will return nan, nan, nan if the provided Vector3's XZ components are both 0.
IsPointInBlock
Checks if the given point is within the Part's extents.
Math.IsPointInBlock(position: Vector3, block: Part): booleanLerp
Linear interpolation between two numbers.
Math.Lerp(value1: number, value2: number, alpha: number): numberTIP
Redundant - Please use math.map(...) instead.
ScaleCFPos
Multiplies a CFrame's XYZ components.
Math.ScaleCFPos(cf: CFrame, scale: number): CFrameSlerp
Returns a unit Vector3 interpolation using a circular curve.
Math.Slerp(vStart: Vector3, vEnd: Vector3, alpha: number): Vector3Vec2LengthSquared
Returns the squared sum of the XY components for a Vector2.
Math.Vec2LengthSquared(vec: Vector2): numberDANGER
Misleading Name - This method returns a sum of components, not length/magnitude.
Vec3LengthSquared
Returns the squared sum of the XYZ components for a Vector3.
Math.Vec3LengthSquared(vec: Vector3): numberDANGER
Misleading Name - This method returns a sum of components, not length/magnitude.
VecAxisAngle
Rotates the given Vector3 along an axis in radians.
Math.VecAxisAngle(srcVec: Vector3, axisVec: Vector3, angle: number): Vector3VecCLerp
Linear interpolation between two Vector3s with alpha clamped to [0, 1].
Math.VecCLerp(start: Vector3, goal: Vector3, alpha: number): Vector3TIP
Redundant - Please use Vector3:Lerp(..., math.clamp(...)) instead.
VecDeadzone
Sets the XYZ components of a Vector3 which have an absolute value below a specified threshold to 0.
Math.VecDeadzone(vec: Vector3, deadzone: number): Vector3VecXZLength
Returns the magnitude of a Vector3 while ignoring the Y component.
Math.VecXZLength(vec: Vector3): numberVecXZLengthSquared
Returns the squared sum of the XZ components for a Vector3.
Math.VecXZLengthSquared(vec: Vector3): numberDANGER
Misleading Name - This method returns a sum of components, not length/magnitude.
ZenoLerp
Linear interpolation between two numbers with an added tolerance parameter.
Math.ZenoLerp(value1: number, value2: number, alpha: number, epsilon: number): numberDANGER
Misleading Name - This method uses linear interpolation, not easing.
TIP
Redundant - Please use math.map(...) instead.