I played around with matrixes again and I still can't get it to work.
Function RotateVector3(X#, Y#, Z#, AngleX#, AngleY#, AngleZ#)
ResultVector = 1
NULL = Make Vector4(ResultVector)
VectorSource = 2
NULL = Make Vector4(VectorSource)
RotationMatrix = 3
NULL = Make Matrix4(RotationMatrix)
Matrix1 = 4
NULL = Make Matrix4(Matrix1)
Matrix2 = 5
NULL = Make Matrix4(Matrix2)
` Set The Source Vector
Set Vector4 VectorSource, X#, Y#, Z#, 1.0
` X Rotate
Set Matrix4 Matrix1, 1, 0, 0, 0, 0, Cos(XAngle#), (0 - Sin(XAngle#)), 0, 0, Sin(XAngle#), Cos(XAngle#), 0, 0, 0, 0, 1
` Y Rotate
Set Matrix4 Matrix2, Cos(YAngle#), 0, Sin(YAngle#), 0, 0, 1, 0, 0, (0 - Sin(YAngle#)), 0, Cos(YAngle#), 0, 0, 0, 0, 1
Multiply Matrix4 RotationMatrix, Matrix1, Matrix2
Copy Matrix4 Matrix1, RotationMatrix
` Z Rotate
Set Matrix4 Matrix2, Cos(ZAngle#), (0 - Sin(ZAngle#)), 0, 0, Sin(ZAngle#), Cos(ZAngle#), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
` The Result is Rotation Matrix
Multiply Matrix4 RotationMatrix, Matrix1, Matrix2
` Apply the rotation matrix
Transform Vector4 ResultVector, VectorSource, RotationMatrix
NULL = Delete Matrix4(RotationMatrix)
NULL = Delete Matrix4(Matrix1)
NULL = Delete Matrix4(Matrix2)
NULL = Delete Vector3(VectorSource)
EndFunction ResultVector
Edit:
Took the rotation matrix from the working example and it seemed to work. I think my math might be off somewhere in the rotation matrix. It almost makes matrixes un-necessary.
Function RotateVector3(X#, Y#, Z#, AngleX#, AngleY#, AngleZ#)
ResultVector = 1
NULL = Make Vector4(ResultVector)
VectorSource = 2
NULL = Make Vector4(VectorSource)
RotationMatrix = 3
NULL = Make Matrix4(RotationMatrix)
`Matrix1 = 4
`NULL = Make Matrix4(Matrix1)
`Matrix2 = 5
`NULL = Make Matrix4(Matrix2)
` Set The Source Vector
Set Vector4 VectorSource, X#, Y#, Z#, 1.0
` X Rotate
`Set Matrix4 Matrix1, 1, 0, 0, 0, 0, Cos(XAngle#), (0 - Sin(XAngle#)), 0, 0, Sin(XAngle#), Cos(XAngle#), 0, 0, 0, 0, 1
` Y Rotate
`Set Matrix4 Matrix2, Cos(YAngle#), 0, Sin(YAngle#), 0, 0, 1, 0, 0, (0 - Sin(YAngle#)), 0, Cos(YAngle#), 0, 0, 0, 0, 1
`Multiply Matrix4 RotationMatrix, Matrix1, Matrix2
`Copy Matrix4 Matrix1, RotationMatrix
` Z Rotate
`Set Matrix4 Matrix2, Cos(ZAngle#), (0 - Sin(ZAngle#)), 0, 0, Sin(ZAngle#), Cos(ZAngle#), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
` The Result is Rotation Matrix
`Multiply Matrix4 RotationMatrix, Matrix1, Matrix2
X1# = (COS(AngleZ#) * COS(AngleY#)) + (SIN(AngleZ#) * SIN(AngleX#) * SIN(AngleY#))
Y1# = (SIN(AngleZ#) * COS(AngleY#)) - (COS(AngleZ#) * SIN(AngleX#) * SIN(AngleY#))
Z1# = COS(AngleX#) * SIN(AngleY#)
X2# = - (SIN(AngleZ#) * COS(AngleX#))
Y2# = COS(AngleZ#) * COS(AngleX#)
Z2# = SIN(AngleX#)
X3# = (SIN(AngleZ#) * SIN(AngleX#) * COS(AngleY#)) - (COS(AngleZ#) * SIN(AngleY#))
Y3# = - (COS(AngleZ#) * SIN(AngleX#) * COS(AngleY#)) - (SIN(AngleZ#) * SIN(AngleY#))
Z3# = COS(AngleX#) * COS(AngleY#)
Set Matrix4 RotationMatrix, X1#, X2#, X3#, 0, Y1#, Y2#, Z3#, 0, Z1#, Z2#, Z3#, 0, 0, 0, 0, 1.0
` Apply the rotation matrix
Transform Vector4 ResultVector, VectorSource, RotationMatrix
NULL = Delete Matrix4(RotationMatrix)
`NULL = Delete Matrix4(Matrix1)
`NULL = Delete Matrix4(Matrix2)
NULL = Delete Vector3(VectorSource)
EndFunction ResultVector