'Use the systems math class Imports System.Math ''' ''' Multiply 2 incoming 4 x 4 matrices and ''' ''' A matrix as a 4 x 4 array of doubles. ''' A matrix as a 4 x 4 array of doubles. ''' Return a the product as a matrix (4 x 4 array of doubles). ''' Public Function MultiplyMatrix(ByVal mat1 As Object, ByVal mat2 As Object) As Object Dim result(3, 3) As Double Dim i As Integer Dim j As Integer Dim k As Integer For i = 0 To 3 For j = 0 To 3 For k = 0 To 3 result(i, j) = result(i, j) + (mat1(i, k) * mat2(k, j)) Next k Next j Next i Return result End Function ''' ''' Transform a point by multiplying it by a transformation matrix. ''' ''' A point as a 3 element (X, Y, Z) aray of doubles. ''' A matrix as a 4 x 4 array of doubles. ''' Return a transformed point as a 3 element aray of doubles. ''' For converting points based on Coordinate systems, Rotating, and Scaling. Public Function TransformPoint(ByVal pt As Object, ByVal mat As Object) As Object Dim result(2) As Double result(0) = (pt(0) * mat(0, 0)) + (pt(1) * mat(0, 1)) + (pt(2) * mat(0, 2)) + (1 * mat(0, 3)) result(1) = (pt(0) * mat(1, 0)) + (pt(1) * mat(1, 1)) + (pt(2) * mat(1, 2)) + (1 * mat(1, 3)) result(2) = (pt(0) * mat(2, 0)) + (pt(1) * mat(2, 1)) + (pt(2) * mat(2, 2)) + (1 * mat(2, 3)) Return result End Function