, Visual C#


         

ByVal Cy As Single, ByVal


ByVal Cx As Single, _
ByVal Cy As Single, ByVal Cz As Single, _
ByVal Fx As Single, ByVal Fy As Single, _
ByVal Fz As Single, ByVal ux As Single, _
ByVal uy As Single, ByVal uz As Single)
Static M1(4, 4) As Single : Static M2(4, 4) As Single
Static M3(4, 4) As Single : Static M4(4, 4) As Single
Static M5(4, 4) As Single : Static M12(4, 4) As Single
Static M34(4, 4) As Single
Static M1234(4, 4) As Single
Dim sin1 As Single : Dim cos1 As Single
Dim sin2 As Single : Dim cos2 As Single
Dim sin3 As Single : Dim cos3 As Single
Dim A As Single : Dim B As Single
Dim C As Single : Dim d1 As Single
Dim d2 As Single : Dim d3 As Single
Dim up1(4) As Single : Dim up2(4) As Single
' ( ) :
MatrixTranslate(M1, -Fx, -Fy, -Fz)
A = Cx - Fx : B = Cy - Fy : C = Cz - Fz
d1 = CSng(Sqrt(A * A + C * C))
If d1 <> 0 Then
sin1 = -A / d1 : cos1 = C / d1
End If
d2 = CSng(Sqrt(A * A + B * B + C * C))
If d2 <> 0 Then
sin2 = B / d2 : cos2 = d1 / d2
End If
' y,
' y-z :
MatrixIdentity(M2)
' d1 = 0,
' y y-z :
If d1 <> 0 Then
M2(1, 1) = cos1 : M2(1, 3) = -sin1
M2(3, 1) = sin1 : M2(3, 3) = cos1
End If
' x,
' Z.
MatrixIdentity(M3)
' d2 = 0,
' .
' .
If d2 <> 0 Then
M3(2, 2) = cos2 : M3(2, 3) = sin2
M3(3, 2) = -sin2 : M3(3, 3) = cos2
End If
' UP: