Faster RotationMatrix, IsEven bit shift and, work on MakeProperty module

This commit is contained in:
2024-04-22 16:57:42 -04:00
parent e3104595d8
commit 431ec165b8
6 changed files with 54 additions and 52 deletions

View File

@@ -27,6 +27,7 @@ export type Math = {
InOutBack: EaseFunction,
OutBounce: EaseFunction,
InQuad: EaseFunction,
IsEven: (n: number) -> boolean,
RotationMatrix: (X: number, Y: number, Z: number) -> RotationMatrix,
Scalar: (X1: number, Y1: number, X2: number, Y2: number) -> Scalar,
maxmin: (min: number, n: number, max: number) -> number
@@ -34,18 +35,26 @@ export type Math = {
local Math = {} :: Math
function Math.IsEven(n)
return bit32.band(n, 1) == 0
end
function Math.maxmin(min, n, max)
return math.max(min, math.min(n, max))
end
function Math.RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
local cosX, sinX = math.cos(X), math.sin(X)
local cosY, sinY = math.cos(Y), math.sin(Y)
local cosZ, sinZ = math.cos(Z), math.sin(Z)
return {
Ixx = math.cos(Z)*math.cos(X)-math.sin(Z)*math.sin(X)*math.sin(Y);
Ixy = math.cos(Z)*math.sin(X)*math.sin(Y)+math.sin(Z)*math.cos(X);
Iyx = -math.cos(Z)*math.sin(X)-math.sin(Z)*math.cos(X)*math.sin(Y);
Iyy = math.cos(Z)*math.cos(X)*math.sin(Y)-math.sin(Z)*math.sin(X);
Izx = -math.sin(Z)*math.cos(Y);
Izy = math.cos(Z)*math.sin(Y)
Ixx = cosZ*cosX-sinZ*sinX*sinY,
Ixy = cosZ*sinX*sinY+sinZ*cosX,
Iyx = -cosZ*sinX-sinZ*cosX*sinY,
Iyy = cosZ*cosX*sinY-sinZ*sinX,
Izx = -sinZ*cosY,
Izy = cosZ*sinY
}
end

View File

@@ -0,0 +1,13 @@
--!optimize 2
--!native
--!strict
--[[
Module.Property = MakeProperty.constructor()
]]
local function MakeProperty<T>()
end
return MakeProperty

View File

@@ -1,24 +0,0 @@
--!optimize 2
--!native
--!strict
local StringModule = {}
StringModule.__index = StringModule
function StringModule.new(String: string)
return setmetatable({
String = String
}, StringModule)
end
type ByteArray = {string}
function StringModule:bytes(): ByteArray
local cbytes = {self.String:byte(1,-1)}
for i = 1, #cbytes do
cbytes[i] = tostring(cbytes[i]):char()
end
return cbytes
end
return StringModule