, Visual C#


- 14


up1(1) = ux : up1(2) = uy : up1(3) = uz

up1(4) = 1 : MatrixApply(up1, M2, up2)

MatrixApply(up2, M3, up1)

' Rotate around the Z axis to put the UP

' vector in the Y-Z plane.

' z,

' UP y-z :

d3 = CSng(Sqrt(up1(1) * up1(1) + _

up1(2) * up1(2)))

MatrixIdentity(M4)

' d3 = 0, UP :

If d3 <> 0 Then

sin3 = up1(1) / d3 : cos3 = up1(2) / d3

M4(1, 1) = cos3 : M4(1, 2) = sin3

M4(2, 1) = -sin3 : M4(2, 2) = cos3

End If

':

If type_of_projection = _

PerspectiveProjection And d2 <> 0 Then

MatrixPerspectiveXZ(M5, d2)

Else

MatrixIdentity(M5)

End If

' :

m3MatMultiply(M12, M1, M2)

m3MatMultiply(M34, M3, M4)

m3MatMultiply(M1234, M12, M34)

If type_of_projection = PerspectiveProjection Then

m3MatMultiplyFull(M, M1234, M5)

Else

m3MatMultiply(M, M1234, M5)

End If

End Sub

' (3-D transformation matrix)

' (perspective projection):

' (r, phi, theta),

' (fx, fy, fx),

' UP <ux, yx, uz>,

' (type_of_projection):

'PerspectiveProjection:

Public Sub Projection(ByRef M(,) As Single, _

ByVal type_of_projection As Integer, ByVal R As Single, _

ByVal phi As Single, ByVal theta 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)

Dim Cx As Single : Dim Cy As Single

Dim Cz As Single : Dim r2 As Single

' :

Cy = R * CSng(Sin(phi))