, Visual C#


- 18


' z-:

Else

' z , ,

' :

Result(3) = Single.MaxValue

End If

Result(4) = 1

End Sub

' :

Public Sub MatrixApply(ByRef V() As Single, _

ByRef M(,) As Single, ByRef Result() As Single)

Result(1) = V(1) * M(1, 1) + V(2) * M(2, 1) + _

V(3) * M(3, 1) + M(4, 1)

Result(2) = V(1) * M(1, 2) + V(2) * M(2, 2) + _

V(3) * M(3, 2) + M(4, 2)

Result(3) = V(1) * M(1, 3) + V(2) * M(2, 3) + _

V(3) * M(3, 3) + M(4, 3)

Result(4) = 1

End Sub

' .

' 0, 0, 0, 1 :

Public Sub m3MatMultiplyFull(ByRef Result(,) As Single, _

ByRef A(,) As Single, ByRef B(,) As Single)

Dim i As Integer : Dim j As Integer

Dim k As Integer : Dim value As Single

For i = 1 To 4

For j = 1 To 4

value = 0

For k = 1 To 4

value = value + A(i, k) * B(k, j)

Next k

Result(i, j) = value

Next

Next

End Sub

' :

Public Sub m3MatMultiply(ByRef Result(,) As Single, _

ByRef A(,) As Single, ByRef B(,) As Single)

Result(1, 1) = A(1, 1) * B(1, 1) + A(1, 2) * B(2, 1) _

+ A(1, 3) * B(3, 1)

Result(1, 2) = A(1, 1) * B(1, 2) + A(1, 2) * B(2, 2) _

+ A(1, 3) * B(3, 2)

Result(1, 3) = A(1, 1) * B(1, 3) + A(1, 2) * B(2, 3) _

+ A(1, 3) * B(3, 3)

Result(1, 4) = 0

Result(2, 1) = A(2, 1) * B(1, 1) + A(2, 2) * B(2, 1) _

+ A(2, 3) * B(3, 1)

Result(2, 2) = A(2, 1) * B(1, 2) + A(2, 2) * B(2, 2) _

+ A(2, 3) * B(3, 2)

Result(2, 3) = A(2, 1) * B(1, 3) + A(2, 2) * B(2, 3) _

+ A(2, 3) * B(3, 3)




- -  - -  - -