Posted 02 June 2016 - 06:35 AM
So I just got done porting a Matrix4f and a Vector4f api to lua. Decided to release the source in case anyone else needed them. So, here you go.
Matrix4: ewsWU1RZ
Vector4: M45y8y5z
They are created OOP style for your convenience
Usage:
Matrix4f:
Vector4f:
PS: If you don't know what these functions do, then you probably don't need these APIs.
Note: These apis were ported from this github repo
Please report any bugs you find here and I will fix them! :D/> Thanks!
Matrix4: ewsWU1RZ
Vector4: M45y8y5z
They are created OOP style for your convenience
Usage:
- Load them in with dofile
Spoiler
dofile("matrix4f")
- To create a matrix4 or vector4 just call Matrix4f() or Vector4f() and an object will be returned
Spoiler
local myNewMatrix = Matrix4f()
local myNewVector = Vector4f(3,5,6,1)
Matrix4f:
Spoiler
- Matrix4f()
- Matrix4f:InitIdentity()
- Matrix4f:InitScreenSpaceTransform(float halfWidth, float halfHeight)
- Matrix4f:InitTranslation(float x, float y, float z)
- Matrix4f:InitRotation(float x, float y, float z, float angle)
- Matrix4f:InitRotation(float x, float y, float z)
- Matrix4f:InitScale(float x, float y, float z)
- Matrix4f:InitPerspective(float fov, float aspectRatio, float zNear, float zFar)
- Matrix4f:InitOrthographic(float left, float right, float bottom, float top, float near, float far)
- Matrix4f:InitRotation(Vector4f forward, Vector4f up)
- Matrix4f:InitRotation(Vector4f forward, Vector4f up, Vector4f right)
- Matrix4f:Transform(Vector4f r)
- Matrix4f:Mul(Matrix4f r)
- Matrix4f:GetM()
- Matrix4f:Get(int x, int y)
- Matrix4f:SetM(float[][] m)
- Matrix4f:Set(int x, int y, float value)
Vector4f:
Spoiler
- Vector4f(float x, float y, float z, float w)
- Vector4f:Length()
- Vector4f:Max()
- Vector4f:Dot(Vector4f r)
- Vector4f:Cross(Vector4f r)
- Vector4f:Normalized()
- Vector4f:Rotate(Vector4f axis, float angle)
- Vector4f:Lerp(Vector4f dest, float lerpFactor)
- Vector4f:Add(Vector4f r)
- Vector4f:Add(float r)
- Vector4f:Sub(Vector4f r)
- Vector4f:Sub(float r)
- Vector4f:Mul(Vector4f r)
- Vector4f:Mul(float r)
- Vector4f:Div(Vector4f r)
- Vector4f:Div(float r)
- Vector4f:Abs()
- Vector4f:toString()
- Vector4f:GetX()
- Vector4f:GetY()
- Vector4f:GetZ()
- Vector4f:GetW()
- Vector4f:equals(Vector4f r)
PS: If you don't know what these functions do, then you probably don't need these APIs.
Note: These apis were ported from this github repo
Please report any bugs you find here and I will fix them! :D/> Thanks!