bowser499
Member
- Reaction score
- 1
Code:
//library Math:
//~~REQUIRES: udg_VectorHash | udg_Matrix3Hash | udg_Matrix4Hash - Hashtable ~~
//~~ udg_VECTOR3_Zero | udg_VECTOR3_oneX | udg_VECTOR3_oneY | udg_VECTOR3_oneZ - Integer ~~
//~~ udg_MATRIX3_Zero | udg_MATRIX3_E | udg_MATRIX4_Zero | udg_MATRIX4_E - Integer ~~
function R2I_n takes real r returns integer
local integer i = R2I(r)
if r < I2R(i)+.5 then
return i
else
return i+1
endif
endfunction
//=====================================================================
function SetVectorX takes integer vec, real x returns nothing
call SaveReal(udg_VectorHash,vec,0,x)
endfunction
function SetVectorY takes integer vec, real y returns nothing
call SaveReal(udg_VectorHash,vec,1,y)
endfunction
function SetVectorZ takes integer vec, real z returns nothing
call SaveReal(udg_VectorHash,vec,2,z)
endfunction
function GetVectorX takes integer vec returns real
return LoadReal(udg_VectorHash,vec,0)
endfunction
function GetVectorY takes integer vec returns real
return LoadReal(udg_VectorHash,vec,1)
endfunction
function GetVectorZ takes integer vec returns real
return LoadReal(udg_VectorHash,vec,2)
endfunction
//=====================================================================
function GetMatrix3m11 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,0)
endfunction
function GetMatrix3m12 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,1)
endfunction
function GetMatrix3m13 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,2)
endfunction
function GetMatrix3m21 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,3)
endfunction
function GetMatrix3m22 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,4)
endfunction
function GetMatrix3m23 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,5)
endfunction
function GetMatrix3m31 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,6)
endfunction
function GetMatrix3m32 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,7)
endfunction
function GetMatrix3m33 takes integer m returns real
return LoadReal(udg_Matrix3Hash,m,8)
endfunction
function SetMatrix3m11 takes integer m, real m11 returns nothing
call SaveReal(udg_Matrix3Hash,m,0,m11)
endfunction
function SetMatrix3m12 takes integer m, real m12 returns nothing
call SaveReal(udg_Matrix3Hash,m,1,m12)
endfunction
function SetMatrix3m13 takes integer m, real m13 returns nothing
call SaveReal(udg_Matrix3Hash,m,2,m13)
endfunction
function SetMatrix3m21 takes integer m, real m21 returns nothing
call SaveReal(udg_Matrix3Hash,m,3,m21)
endfunction
function SetMatrix3m22 takes integer m, real m22 returns nothing
call SaveReal(udg_Matrix3Hash,m,4,m22)
endfunction
function SetMatrix3m23 takes integer m, real m23 returns nothing
call SaveReal(udg_Matrix3Hash,m,5,m23)
endfunction
function SetMatrix3m31 takes integer m, real m31 returns nothing
call SaveReal(udg_Matrix3Hash,m,6,m31)
endfunction
function SetMatrix3m32 takes integer m, real m32 returns nothing
call SaveReal(udg_Matrix3Hash,m,7,m32)
endfunction
function SetMatrix3m33 takes integer m, real m33 returns nothing
call SaveReal(udg_Matrix3Hash,m,8,m33)
endfunction
//=====================================================================
function GetMatrix4m11 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,0)
endfunction
function GetMatrix4m12 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,1)
endfunction
function GetMatrix4m13 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,2)
endfunction
function GetMatrix4m14 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,3)
endfunction
function GetMatrix4m21 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,4)
endfunction
function GetMatrix4m22 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,5)
endfunction
function GetMatrix4m23 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,6)
endfunction
function GetMatrix4m24 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,7)
endfunction
function GetMatrix4m31 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,8)
endfunction
function GetMatrix4m32 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,9)
endfunction
function GetMatrix4m33 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,10)
endfunction
function GetMatrix4m34 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,11)
endfunction
function GetMatrix4m41 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,12)
endfunction
function GetMatrix4m42 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,13)
endfunction
function GetMatrix4m43 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,14)
endfunction
function GetMatrix4m44 takes integer m returns real
return LoadReal(udg_Matrix4Hash,m,15)
endfunction
function SetMatrix4m11 takes integer m, real m11 returns nothing
call SaveReal(udg_Matrix4Hash,m,0,m11)
endfunction
function SetMatrix4m12 takes integer m, real m12 returns nothing
call SaveReal(udg_Matrix4Hash,m,1,m12)
endfunction
function SetMatrix4m13 takes integer m, real m13 returns nothing
call SaveReal(udg_Matrix4Hash,m,2,m13)
endfunction
function SetMatrix4m14 takes integer m, real m14 returns nothing
call SaveReal(udg_Matrix4Hash,m,3,m14)
endfunction
function SetMatrix4m21 takes integer m, real m21 returns nothing
call SaveReal(udg_Matrix4Hash,m,4,m21)
endfunction
function SetMatrix4m22 takes integer m, real m22 returns nothing
call SaveReal(udg_Matrix4Hash,m,5,m22)
endfunction
function SetMatrix4m23 takes integer m, real m23 returns nothing
call SaveReal(udg_Matrix4Hash,m,6,m23)
endfunction
function SetMatrix4m24 takes integer m, real m24 returns nothing
call SaveReal(udg_Matrix4Hash,m,7,m24)
endfunction
function SetMatrix4m31 takes integer m, real m31 returns nothing
call SaveReal(udg_Matrix4Hash,m,8,m31)
endfunction
function SetMatrix4m32 takes integer m, real m32 returns nothing
call SaveReal(udg_Matrix4Hash,m,9,m32)
endfunction
function SetMatrix4m33 takes integer m, real m33 returns nothing
call SaveReal(udg_Matrix4Hash,m,10,m33)
endfunction
function SetMatrix4m34 takes integer m, real m34 returns nothing
call SaveReal(udg_Matrix4Hash,m,11,m34)
endfunction
function SetMatrix4m41 takes integer m, real m41 returns nothing
call SaveReal(udg_Matrix4Hash,m,12,m41)
endfunction
function SetMatrix4m42 takes integer m, real m42 returns nothing
call SaveReal(udg_Matrix4Hash,m,13,m42)
endfunction
function SetMatrix4m43 takes integer m, real m43 returns nothing
call SaveReal(udg_Matrix4Hash,m,14,m43)
endfunction
function SetMatrix4m44 takes integer m, real m44 returns nothing
call SaveReal(udg_Matrix4Hash,m,15,m44)
endfunction
//=====================================================================
function CreateVector_0 takes nothing returns integer
local integer i = LoadInteger(udg_VectorHash,0,0) + 1
call SetVectorX(i,0.)
call SetVectorY(i,0.)
call SetVectorZ(i,0.)
call SaveInteger(udg_VectorHash,0,0,i)
return i
endfunction
function CreateVector_1 takes real x, real y, real z returns integer
local integer i = LoadInteger(udg_VectorHash,0,0) + 1
call SetVectorX(i,x)
call SetVectorY(i,y)
call SetVectorZ(i,z)
call SaveInteger(udg_VectorHash,0,0,i)
return i
endfunction
function CreateVector_2 takes integer v returns integer
local integer i = LoadInteger(udg_VectorHash,0,0) + 1
call SetVectorX(i,GetVectorX(v))
call SetVectorY(i,GetVectorY(v))
call SetVectorZ(i,GetVectorZ(v))
call SaveInteger(udg_VectorHash,0,0,i)
return i
endfunction
function SetVectorValues takes integer v, real x, real y, real z returns integer
call SetVectorX(v,x)
call SetVectorY(v,y)
call SetVectorZ(v,z)
return v
endfunction
function GetVectorLength takes integer v returns real
return SquareRoot(GetVectorX(v)*GetVectorX(v)+GetVectorY(v)*GetVectorY(v)+GetVectorZ(v)*GetVectorZ(v))
endfunction
function GetVectorLengthSq takes integer v returns real
return GetVectorX(v)*GetVectorX(v)+GetVectorY(v)*GetVectorY(v)+GetVectorZ(v)*GetVectorZ(v)
endfunction
function GetVectorData takes integer v returns string
return "Vector3 id " + I2S(v) + "\nx = " + R2S(GetVectorX(v)) + " y = " + R2S(GetVectorY(v)) + " z = " + R2S(GetVectorZ(v))
endfunction
function Vec3Add takes integer Output,integer v1,integer v2 returns integer
call SetVectorX(Output,GetVectorX(v1)+GetVectorX(v2))
call SetVectorY(Output,GetVectorY(v1)+GetVectorY(v2))
call SetVectorZ(Output,GetVectorZ(v1)+GetVectorZ(v2))
return Output
endfunction
function Vec3Subtract takes integer Output,integer v1,integer v2 returns integer
call SetVectorX(Output,GetVectorX(v1)-GetVectorX(v2))
call SetVectorY(Output,GetVectorY(v1)-GetVectorY(v2))
call SetVectorZ(Output,GetVectorZ(v1)-GetVectorZ(v2))
return Output
endfunction
function Vec3Scale takes integer Output, integer v, real r returns integer
call SetVectorX(Output,GetVectorX(v)*r)
call SetVectorY(Output,GetVectorY(v)*r)
call SetVectorZ(Output,GetVectorZ(v)*r)
return Output
endfunction
function Vec3Division takes integer Output,integer v,real r returns integer
call SetVectorX(Output,GetVectorX(v)/r)
call SetVectorY(Output,GetVectorY(v)/r)
call SetVectorZ(Output,GetVectorZ(v)/r)
return Output
endfunction
function Vec3Normalize takes integer Output,integer v returns integer
local real len = GetVectorLength(v)
call SetVectorX(Output,GetVectorX(v)/len)
call SetVectorY(Output,GetVectorY(v)/len)
call SetVectorZ(Output,GetVectorZ(v)/len)
return Output
endfunction
function Vec3Dot takes integer v1,integer v2 returns real
return GetVectorX(v1)*GetVectorX(v2)+GetVectorY(v1)*GetVectorY(v2)+GetVectorZ(v1)*GetVectorZ(v2)
endfunction
function Vec3Cross takes integer Output,integer v1,integer v2 returns integer
local real x = GetVectorY(v1)*GetVectorZ(v2)-GetVectorZ(v1)*GetVectorY(v2)
local real y = GetVectorZ(v1)*GetVectorX(v2)-GetVectorX(v1)*GetVectorZ(v2)
local real z = GetVectorX(v1)*GetVectorY(v2)-GetVectorY(v1)*GetVectorX(v2)
call SetVectorX(Output,x)
call SetVectorY(Output,y)
call SetVectorZ(Output,z)
return Output
endfunction
function Vec3Transform_1 takes integer Output,integer v,integer m returns integer
local real x = GetVectorX(v)*GetMatrix3m11(m)+GetVectorY(v)*GetMatrix3m21(m)+GetVectorZ(v)*GetMatrix3m31(m)
local real y = GetVectorX(v)*GetMatrix3m12(m)+GetVectorY(v)*GetMatrix3m22(m)+GetVectorZ(v)*GetMatrix3m32(m)
local real z = GetVectorX(v)*GetMatrix3m13(m)+GetVectorY(v)*GetMatrix3m23(m)+GetVectorZ(v)*GetMatrix3m33(m)
call SetVectorX(Output,x)
call SetVectorY(Output,y)
call SetVectorZ(Output,z)
return Output
endfunction
function Vec3Transform_2 takes integer Output,integer v,integer m returns integer
local real x = GetVectorX(v)*GetMatrix4m11(m)+GetVectorY(v)*GetMatrix4m21(m)+GetVectorZ(v)*GetMatrix4m31(m)+GetMatr?ix4m41(m)
local real y = GetVectorX(v)*GetMatrix4m12(m)+GetVectorY(v)*GetMatrix4m22(m)+GetVectorZ(v)*GetMatrix4m32(m)+GetMatr?ix4m42(m)
local real z = GetVectorX(v)*GetMatrix4m13(m)+GetVectorY(v)*GetMatrix4m23(m)+GetVectorZ(v)*GetMatrix4m33(m)+GetMatr?ix4m43(m)
local real w = GetVectorX(v)*GetMatrix4m14(m)+GetVectorY(v)*GetMatrix4m24(m)+GetVectorZ(v)*GetMatrix4m34(m)+GetMatr?ix4m44(m)
call SetVectorX(Output,x/w)
call SetVectorY(Output,y/w)
call SetVectorZ(Output,z/w)
return Output
endfunction
//=====================================================================
function CreateMatrix3_0 takes nothing returns integer
local integer i = LoadInteger(udg_Matrix3Hash,0,0) + 1
call SetMatrix3m11(i,0.)
call SetMatrix3m12(i,0.)
call SetMatrix3m13(i,0.)
call SetMatrix3m21(i,0.)
call SetMatrix3m22(i,0.)
call SetMatrix3m23(i,0.)
call SetMatrix3m31(i,0.)
call SetMatrix3m32(i,0.)
call SetMatrix3m33(i,0.)
call SaveInteger(udg_Matrix3Hash,0,0,i)
return i
endfunction
function CreateMatrix3_1 takes real r11,real r12,real r13,real r21,real r22,real r23,real r31,real r32,real r33 returns integer
local integer i = LoadInteger(udg_Matrix3Hash,0,0) + 1
call SetMatrix3m11(i,r11)
call SetMatrix3m12(i,r12)
call SetMatrix3m13(i,r13)
call SetMatrix3m21(i,r21)
call SetMatrix3m22(i,r22)
call SetMatrix3m23(i,r23)
call SetMatrix3m31(i,r31)
call SetMatrix3m32(i,r32)
call SetMatrix3m33(i,r33)
call SaveInteger(udg_Matrix3Hash,0,0,i)
return i
endfunction
function CreateMatrix3_2 takes integer m returns integer
local integer i = LoadInteger(udg_Matrix3Hash,0,0) + 1
call SetMatrix3m11(i,GetMatrix3m11(m))
call SetMatrix3m12(i,GetMatrix3m12(m))
call SetMatrix3m13(i,GetMatrix3m13(m))
call SetMatrix3m21(i,GetMatrix3m21(m))
call SetMatrix3m22(i,GetMatrix3m22(m))
call SetMatrix3m23(i,GetMatrix3m23(m))
call SetMatrix3m31(i,GetMatrix3m31(m))
call SetMatrix3m32(i,GetMatrix3m32(m))
call SetMatrix3m33(i,GetMatrix3m33(m))
call SaveInteger(udg_Matrix3Hash,0,0,i)
return i
endfunction
function SetMatrix3Values takes integer m,real r11,real r12,real r13,real r21,real r22,real r23,real r31,real r32,real r33 returns integer
call SetMatrix3m11(m,r11)
call SetMatrix3m12(m,r12)
call SetMatrix3m13(m,r13)
call SetMatrix3m21(m,r21)
call SetMatrix3m22(m,r22)
call SetMatrix3m23(m,r23)
call SetMatrix3m31(m,r31)
call SetMatrix3m32(m,r32)
call SetMatrix3m33(m,r33)
return m
endfunction
function GetMatrix3Data takes integer m returns string
return "Matrux3 id " + I2S(m) + "\n" + R2S(GetMatrix3m11(m)) + " " + R2S(GetMatrix3m12(m)) + " " + R2S(GetMatrix3m13(m)) + "\n" + R2S(GetMatrix3m21(m)) + " " + R2S(GetMatrix3m22(m)) + " " + R2S(GetMatrix3m23(m)) + "\n" + R2S(GetMatrix3m31(m)) + " " + R2S(GetMatrix3m32(m)) + " " + R2S(GetMatrix3m33(m))
endfunction
function Matrix3Multiply takes integer Output,integer m1,integer m2 returns integer
local real r11 = GetMatrix3m11(m1)*GetMatrix3m11(m2)+GetMatrix3m21(m1)*GetMatrix3m12(m2)+GetMatrix3m31(m1)*GetMatrix3?m13(m2)
local real r12 = GetMatrix3m12(m1)*GetMatrix3m11(m2)+GetMatrix3m22(m1)*GetMatrix3m12(m2)+GetMatrix3m32(m1)*GetMatrix3?m13(m2)
local real r13 = GetMatrix3m13(m1)*GetMatrix3m11(m2)+GetMatrix3m23(m1)*GetMatrix3m12(m2)+GetMatrix3m33(m1)*GetMatrix3?m13(m2)
local real r21 = GetMatrix3m11(m1)*GetMatrix3m21(m2)+GetMatrix3m21(m1)*GetMatrix3m22(m2)+GetMatrix3m31(m1)*GetMatrix3?m23(m2)
local real r22 = GetMatrix3m12(m1)*GetMatrix3m21(m2)+GetMatrix3m22(m1)*GetMatrix3m22(m2)+GetMatrix3m32(m1)*GetMatrix3?m23(m2)
local real r23 = GetMatrix3m13(m1)*GetMatrix3m21(m2)+GetMatrix3m23(m1)*GetMatrix3m22(m2)+GetMatrix3m33(m1)*GetMatrix3?m23(m2)
local real r31 = GetMatrix3m11(m1)*GetMatrix3m31(m2)+GetMatrix3m21(m1)*GetMatrix3m32(m2)+GetMatrix3m31(m1)*GetMatrix3?m33(m2)
local real r32 = GetMatrix3m12(m1)*GetMatrix3m31(m2)+GetMatrix3m22(m1)*GetMatrix3m32(m2)+GetMatrix3m32(m1)*GetMatrix3?m33(m2)
local real r33 = GetMatrix3m13(m1)*GetMatrix3m31(m2)+GetMatrix3m23(m1)*GetMatrix3m32(m2)+GetMatrix3m33(m1)*GetMatrix3?m33(m2)
return SetMatrix3Values(Output,r11,r12,r13,r21,r22,r23,r31,r32,r33)
endfunction
function Matrix3Scaling takes integer Output,real x,real y,real z returns integer
return SetMatrix3Values(Output,x,0.,0.,0.,y,0.,0.,0.,z)
endfunction
function Matrix3RotationX takes integer Output,real a returns integer
return SetMatrix3Values(Output,1.,0.,0.,0.,Cos(a),-1.*Sin(a),0.,Sin(a),Cos(a))
endfunction
function Matrix3RotationY takes integer Output,real a returns integer
return SetMatrix3Values(Output,Cos(a),0.,Sin(a),0.,1.,0.,-1.*Sin(a),0.,Cos(a))
endfunction
function Matrix3RotationZ takes integer Output,real a returns integer
return SetMatrix3Values(Output,Cos(a),-1.*Sin(a),0.,Sin(a),Cos(a),0.,0.,0.,1.)
endfunction
function Matrix3RotationAxis takes integer Output,integer v,real a returns integer
local real cosa = Cos(a)
local real sina = Sin(a)
local real r11 = cosa+(1-cosa)*GetVectorX(v)*GetVectorX(v)
local real r12 = (1-cosa)*GetVectorX(v)*GetVectorY(v)-sina*GetVectorZ(v)
local real r13 = (1-cosa)*GetVectorX(v)*GetVectorZ(v)+ sina*GetVectorY(v)
local real r21 = (1-cosa)*GetVectorY(v)*GetVectorX(v)+sina*GetVectorZ(v)
local real r22 = cosa+(1-cosa)*GetVectorY(v)*GetVectorY(v)
local real r23 = (1-cosa)*GetVectorY(v)*GetVectorZ(v)-sina*GetVectorX(v)
local real r31 = (1-cosa)*GetVectorZ(v)*GetVectorX(v)-sina*GetVectorY(v)
local real r32 = (1-cosa)*GetVectorZ(v)*GetVectorY(v)+ sina*GetVectorX(v)
local real r33 = cosa+(1-cosa)*GetVectorZ(v)*GetVectorZ(v)
return SetMatrix3Values(Output,r11,r12,r13,r21,r22,r23,r31,r32,r33)
endfunction
function Matrix3RotationYawPitchRoll takes integer Output,real Yaw,real Pitch,real Roll returns integer
local real cosa = Cos(Yaw)
local real sina = Sin(Yaw)
local real cosb = Cos(Pitch)
local real sinb = Sin(Pitch)
local real cosy = Cos(Roll)
local real siny = Sin(Roll)
local real r11 = cosa*cosb
local real r12 = cosa*sinb*siny-sina*cosy
local real r13 = cosa*sinb*cosy+sina*siny
local real r21 = sina*cosb
local real r22 = sina*sinb*siny+cosa*cosy
local real r23 = sina*sinb*cosy-cosa*siny
local real r31 = -1.*sinb
local real r32 = cosb*siny
local real r33 = cosb*cosy
return SetMatrix3Values(Output,r11,r12,r13,r21,r22,r23,r31,r32,r33)
endfunction
//=====================================================================
function CreateMatrix4_0 takes nothing returns integer
local integer i = LoadInteger(udg_Matrix4Hash,0,0) + 1
call SetMatrix4m11(i,0.)
call SetMatrix4m12(i,0.)
call SetMatrix4m13(i,0.)
call SetMatrix4m14(i,0.)
call SetMatrix4m21(i,0.)
call SetMatrix4m22(i,0.)
call SetMatrix4m23(i,0.)
call SetMatrix4m24(i,0.)
call SetMatrix4m31(i,0.)
call SetMatrix4m32(i,0.)
call SetMatrix4m33(i,0.)
call SetMatrix4m34(i,0.)
call SetMatrix4m41(i,0.)
call SetMatrix4m42(i,0.)
call SetMatrix4m43(i,0.)
call SetMatrix4m44(i,0.)
call SaveInteger(udg_Matrix4Hash,0,0,i)
return i
endfunction
function CreateMatrix4_1 takes real r11,real r12,real r13,real r14,real r21,real r22,real r23,real r24,real r31,real r32,real r33,real r34,real r41,real r42,real r43,real r44 returns integer
local integer i = LoadInteger(udg_Matrix4Hash,0,0) + 1
call SetMatrix4m11(i,r11)
call SetMatrix4m12(i,r12)
call SetMatrix4m13(i,r13)
call SetMatrix4m14(i,r14)
call SetMatrix4m21(i,r21)
call SetMatrix4m22(i,r22)
call SetMatrix4m23(i,r23)
call SetMatrix4m24(i,r24)
call SetMatrix4m31(i,r31)
call SetMatrix4m32(i,r32)
call SetMatrix4m33(i,r33)
call SetMatrix4m34(i,r34)
call SetMatrix4m41(i,r41)
call SetMatrix4m42(i,r42)
call SetMatrix4m43(i,r43)
call SetMatrix4m44(i,r44)
call SaveInteger(udg_Matrix4Hash,0,0,i)
return i
endfunction
function CreateMatrix4_2 takes integer m returns integer
local integer i = LoadInteger(udg_Matrix4Hash,0,0) + 1
call SetMatrix4m11(i,GetMatrix4m11(m))
call SetMatrix4m12(i,GetMatrix4m12(m))
call SetMatrix4m13(i,GetMatrix4m13(m))
call SetMatrix4m14(i,GetMatrix4m14(m))
call SetMatrix4m21(i,GetMatrix4m21(m))
call SetMatrix4m22(i,GetMatrix4m22(m))
call SetMatrix4m23(i,GetMatrix4m23(m))
call SetMatrix4m24(i,GetMatrix4m24(m))
call SetMatrix4m31(i,GetMatrix4m31(m))
call SetMatrix4m32(i,GetMatrix4m32(m))
call SetMatrix4m33(i,GetMatrix4m33(m))
call SetMatrix4m34(i,GetMatrix4m34(m))
call SetMatrix4m41(i,GetMatrix4m41(m))
call SetMatrix4m42(i,GetMatrix4m42(m))
call SetMatrix4m43(i,GetMatrix4m43(m))
call SetMatrix4m44(i,GetMatrix4m44(m))
call SaveInteger(udg_Matrix4Hash,0,0,i)
return i
endfunction
function CreateMatrix4_3 takes integer m returns integer
local integer i = LoadInteger(udg_Matrix4Hash,0,0) + 1
call SetMatrix4m11(i,GetMatrix3m11(m))
call SetMatrix4m12(i,GetMatrix3m12(m))
call SetMatrix4m13(i,GetMatrix3m13(m))
call SetMatrix4m14(i,0.)
call SetMatrix4m21(i,GetMatrix3m21(m))
call SetMatrix4m22(i,GetMatrix3m22(m))
call SetMatrix4m23(i,GetMatrix3m23(m))
call SetMatrix4m24(i,0.)
call SetMatrix4m31(i,GetMatrix3m31(m))
call SetMatrix4m32(i,GetMatrix3m32(m))
call SetMatrix4m33(i,GetMatrix3m33(m))
call SetMatrix4m34(i,0.)
call SetMatrix4m41(i,0.)
call SetMatrix4m42(i,0.)
call SetMatrix4m43(i,0.)
call SetMatrix4m44(i,1.)
call SaveInteger(udg_Matrix4Hash,0,0,i)
return i
endfunction
function SetMatrix4Values takes integer m,real r11,real r12,real r13,real r14,real r21,real r22,real r23,real r24,real r31,real r32,real r33,real r34,real r41,real r42,real r43,real r44 returns integer
call SetMatrix4m11(m,r11)
call SetMatrix4m12(m,r12)
call SetMatrix4m13(m,r13)
call SetMatrix4m14(m,r14)
call SetMatrix4m21(m,r21)
call SetMatrix4m22(m,r22)
call SetMatrix4m23(m,r23)
call SetMatrix4m24(m,r24)
call SetMatrix4m31(m,r31)
call SetMatrix4m32(m,r32)
call SetMatrix4m33(m,r33)
call SetMatrix4m34(m,r34)
call SetMatrix4m41(m,r41)
call SetMatrix4m42(m,r42)
call SetMatrix4m43(m,r43)
call SetMatrix4m44(m,r44)
return m
endfunction
function GetMatrix4Data takes integer m returns string
return "Matrux4 id " + I2S(m) + "\n" + R2S(GetMatrix4m11(m)) + " " + R2S(GetMatrix4m12(m)) + " " + R2S(GetMatrix4m13(m)) + " " + R2S(GetMatrix4m14(m)) + "\n" + R2S(GetMatrix4m21(m)) + " " + R2S(GetMatrix4m22(m)) + " " + R2S(GetMatrix4m23(m)) + " " + R2S(GetMatrix4m24(m)) + "\n" + R2S(GetMatrix4m31(m)) + " " + R2S(GetMatrix4m32(m)) + " " + R2S(GetMatrix4m33(m)) + " " + R2S(GetMatrix4m34(m)) + "\n" + R2S(GetMatrix4m41(m)) + " " + R2S(GetMatrix4m42(m)) + " " + R2S(GetMatrix4m43(m)) + " " + R2S(GetMatrix4m44(m))
endfunction
function Matrix4Multiply takes integer Output,integer m1,integer m2 returns integer
local real r11 = GetMatrix4m11(m1)*GetMatrix4m11(m2)+GetMatrix4m21(m1)*GetMatrix4m12(m2)+GetMatrix4m31(m1)*GetMatrix4?m13(m2)+GetMatrix4m41(m1)*GetMatrix4m14(m2)
local real r12 = GetMatrix4m12(m1)*GetMatrix4m11(m2)+GetMatrix4m22(m1)*GetMatrix4m12(m2)+GetMatrix4m32(m1)*GetMatrix4?m13(m2)+GetMatrix4m42(m1)*GetMatrix4m14(m2)
local real r13 = GetMatrix4m13(m1)*GetMatrix4m11(m2)+GetMatrix4m23(m1)*GetMatrix4m12(m2)+GetMatrix4m33(m1)*GetMatrix4?m13(m2)+GetMatrix4m43(m1)*GetMatrix4m14(m2)
local real r14 = GetMatrix4m14(m1)*GetMatrix4m11(m2)+GetMatrix4m24(m1)*GetMatrix4m12(m2)+GetMatrix4m34(m1)*GetMatrix4?m13(m2)+GetMatrix4m44(m1)*GetMatrix4m14(m2)
local real r21 = GetMatrix4m11(m1)*GetMatrix4m21(m2)+GetMatrix4m21(m1)*GetMatrix4m22(m2)+GetMatrix4m31(m1)*GetMatrix4?m23(m2)+GetMatrix4m41(m1)*GetMatrix4m24(m2)
local real r22 = GetMatrix4m12(m1)*GetMatrix4m21(m2)+GetMatrix4m22(m1)*GetMatrix4m22(m2)+GetMatrix4m32(m1)*GetMatrix4?m23(m2)+GetMatrix4m42(m1)*GetMatrix4m24(m2)
local real r23 = GetMatrix4m13(m1)*GetMatrix4m21(m2)+GetMatrix4m23(m1)*GetMatrix4m22(m2)+GetMatrix4m33(m1)*GetMatrix4?m23(m2)+GetMatrix4m43(m1)*GetMatrix4m24(m2)
local real r24 = GetMatrix4m14(m1)*GetMatrix4m21(m2)+GetMatrix4m24(m1)*GetMatrix4m22(m2)+GetMatrix4m34(m1)*GetMatrix4?m23(m2)+GetMatrix4m44(m1)*GetMatrix4m24(m2)
local real r31 = GetMatrix4m11(m1)*GetMatrix4m31(m2)+GetMatrix4m21(m1)*GetMatrix4m32(m2)+GetMatrix4m31(m1)*GetMatrix4?m33(m2)+GetMatrix4m41(m1)*GetMatrix4m34(m2)
local real r32 = GetMatrix4m12(m1)*GetMatrix4m31(m2)+GetMatrix4m22(m1)*GetMatrix4m32(m2)+GetMatrix4m32(m1)*GetMatrix4?m33(m2)+GetMatrix4m42(m1)*GetMatrix4m34(m2)
local real r33 = GetMatrix4m13(m1)*GetMatrix4m31(m2)+GetMatrix4m22(m1)*GetMatrix4m32(m2)+GetMatrix4m33(m1)*GetMatrix4?m33(m2)+GetMatrix4m43(m1)*GetMatrix4m34(m2)
local real r34 = GetMatrix4m14(m1)*GetMatrix4m31(m2)+GetMatrix4m24(m1)*GetMatrix4m32(m2)+GetMatrix4m34(m1)*GetMatrix4?m33(m2)+GetMatrix4m44(m1)*GetMatrix4m34(m2)
local real r41 = GetMatrix4m11(m1)*GetMatrix4m41(m2)+GetMatrix4m21(m1)*GetMatrix4m42(m2)+GetMatrix4m31(m1)*GetMatrix4?m43(m2)+GetMatrix4m41(m1)*GetMatrix4m44(m2)
local real r42 = GetMatrix4m12(m1)*GetMatrix4m41(m2)+GetMatrix4m22(m1)*GetMatrix4m42(m2)+GetMatrix4m32(m1)*GetMatrix4?m43(m2)+GetMatrix4m42(m1)*GetMatrix4m44(m2)
local real r43 = GetMatrix4m13(m1)*GetMatrix4m41(m2)+GetMatrix4m23(m1)*GetMatrix4m42(m2)+GetMatrix4m33(m1)*GetMatrix4?m43(m2)+GetMatrix4m43(m1)*GetMatrix4m44(m2)
local real r44 = GetMatrix4m14(m1)*GetMatrix4m41(m2)+GetMatrix4m24(m1)*GetMatrix4m42(m2)+GetMatrix4m34(m1)*GetMatrix4?m43(m2)+GetMatrix4m44(m1)*GetMatrix4m44(m2)
return SetMatrix4Values(Output,r11,r12,r13,r14,r21,r22,r23,r24,r31,r32,r33,r34,r41,r42,r43,r44)
endfunction
function InitMathLib takes nothing returns nothing
set udg_VECTOR3_Zero = CreateVector_0()
set udg_VECTOR3_oneX = CreateVector_1(1.,0.,0.)
set udg_VECTOR3_oneY = CreateVector_1(0.,1.,0.)
set udg_VECTOR3_oneZ = CreateVector_1(0.,0.,1.)
set udg_MATRIX3_Zero = CreateMatrix3_0()
set udg_MATRIX3_E = CreateMatrix3_1(1.,0.,0.,0.,1.,0.,0.,0.,1.)
set udg_MATRIX4_Zero = CreateMatrix4_0()
set udg_MATRIX4_E = CreateMatrix4_1(1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.)
endfunction
//library Math ends