mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Rotation matrix UI and Interactions dir
This commit is contained in:
@@ -7,16 +7,52 @@
|
||||
type EaseFunction = (n: number) -> number
|
||||
type LinearFunction = (a: number, b: number, t: number) -> number
|
||||
|
||||
export type RotationMatrix = {
|
||||
Ixx: number,
|
||||
Ixy: number,
|
||||
Iyx: number,
|
||||
Iyy: number,
|
||||
Izx: number,
|
||||
Izy: number
|
||||
}
|
||||
|
||||
export type Scalar = {
|
||||
Distance: number,
|
||||
Center: Vector2,
|
||||
Rotation: number
|
||||
}
|
||||
|
||||
export type Math = {
|
||||
Linear: LinearFunction,
|
||||
InOutBack: EaseFunction,
|
||||
OutBounce: EaseFunction,
|
||||
InQuad: EaseFunction,
|
||||
RotationMatrix: (X: number, Y: number, Z: number) -> RotationMatrix,
|
||||
Scalar: (X1: number, Y1: number, X2: number, Y2: number) -> Scalar
|
||||
}
|
||||
|
||||
local Math = {} :: Math
|
||||
--Google straight up gives wrong/bad math
|
||||
|
||||
function Math.RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
||||
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)
|
||||
}
|
||||
end
|
||||
|
||||
function Math.Scalar(X1: number, Y1: number, X2: number, Y2: number): Scalar
|
||||
return {
|
||||
Distance = math.sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
|
||||
Center = Vector2.new((X1+X2)/2,(Y1+Y2)/2);
|
||||
Rotation = math.deg(math.atan2(Y1-Y2,X1-X2))
|
||||
}
|
||||
end
|
||||
|
||||
--My versions
|
||||
function Math.Linear(a,b,t)
|
||||
return a-a*t+b*t
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user