matrix3d.cls

来自「《MATLAB实用指南》系列丛书DE源代码」· CLS 代码 · 共 91 行

CLS
91
字号
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Matrix3D"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private mdblM(0 To 3, 0 To 3) As Double

Public Property Let M(ByVal intI As Integer, ByVal intJ As Integer, ByVal dblData As Double)
    mdblM(intI, intJ) = dblData
End Property

Public Property Get M(ByVal intI As Integer, ByVal intJ As Integer) As Double
    M = mdblM(intI, intJ)
End Property

'计算行列式的值
Public Function GetValue() As Double
  GetValue = mdblM(0, 0) * mdblM(1, 1) * mdblM(2, 2) + _
             mdblM(0, 1) * mdblM(1, 2) * mdblM(2, 0) + _
             mdblM(0, 2) * mdblM(1, 0) * mdblM(2, 1) + _
             mdblM(0, 2) * mdblM(1, 1) * mdblM(2, 0) + _
             mdblM(0, 1) * mdblM(1, 0) * mdblM(2, 2) + _
             mdblM(0, 0) * mdblM(1, 2) * mdblM(2, 1)
End Function

'单位矩阵
Public Sub IdenticalMatirx()
  Dim intI As Integer
  Dim intJ As Integer
  For intI = 0 To 3
    For intJ = 0 To 3
      If intI = intJ Then
        mdblM(intI, intJ) = 1#
      Else
        mdblM(intI, intJ) = 0#
      End If
    Next
  Next
End Sub

'矩阵相乘
Public Function Multiply(mtxM As Matrix3D) As Matrix3D
  Dim mtxMult As Matrix3D
  Set mtxMult = New Matrix3D
  
  Dim intI As Integer
  Dim intJ As Integer
  For intI = 0 To 3
    For intJ = 0 To 3
      mtxMult.M(intI, intJ) = mdblM(intI, 0) * mtxM.M(0, intJ) + _
                           mdblM(intI, 1) * mtxM.M(1, intJ) + _
                           mdblM(intI, 2) * mtxM.M(2, intJ) + _
                           mdblM(intI, 3) * mtxM.M(3, intJ)
    Next
  Next
  
  Set Multiply = mtxMult
End Function

'计算平移变换矩阵
Public Function TransT(vctV As Vector3D) As Matrix3D
  '添加代码
End Function

'计算比例变换矩阵
Public Function ScaleT(dblS As Double) As Matrix3D
  '添加代码
End Function

'计算旋转变换矩阵
Public Function RotateT(vctV As Vector3D, dblD As Double) As Matrix3D
  '添加代码
End Function

'计算镜像变换矩阵
Public Function MirrorT(vctV As Vector3D) As Matrix3D
  '添加代码
End Function


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?