, Visual C#


- 7


38.5. .

'

' :

Public Class myClassPoint3D

' 4-

'(original coordinates); :

Public orig_coord(3) As Double

'

'(transformed coordinates):

Public trans_coord(3) As Double

' :

Public Sub New()

End Sub

' :

Public Sub New(ByVal x As Double, ByVal y As Double, _

ByVal z As Double, Optional ByVal myScale As Double = 1)

orig_coord(0) = x

orig_coord(1) = y

orig_coord(2) = z

orig_coord(3) = myScale

End Sub

' (transformation matrix):

Public Function Transformation( _

ByVal matrix As myClassMatrix3D, _

Optional ByVal normalize As Boolean = True) _

As myClassPoint3D

Dim value As Double

Dim result As New myClassPoint3D

For i As Integer = 0 To 3

value = 0

For j As Integer = 0 To 3

value = value + _

orig_coord(j) * matrix.M(j, i)

Next

trans_coord(i) = value

Next

' :

If normalize Then

' value = trans_coord(3):

trans_coord(0) = trans_coord(0) / value

trans_coord(1) = trans_coord(1) / value

trans_coord(2) = trans_coord(2) / value

trans_coord(3) = 1

End If

End Function

End Class

 

'

' :

Public Class myClassMatrix3D

' (matrix) 4x4:

Public M(3, 3) As Double

' :

Public Sub New()

End Sub

' :




- -  - -  - -