Attribute VB_Name = "Module1" Public a_ As Double Public b_ As Double Public c_ As Double Public d_ As Double Public e_ As Double Public f_ As Double Public Sub a_transform_affine(ByVal q As Integer, ByVal direction As Integer, x As Double, y As Double, p_x As Double, p_y As Double) Select Case direction Case 0 ' From camera coordinates to image cordinates (pixels) p_x = a_ * x + b_ * y + c_ p_y = d_ * x + e_ * y + f_ Case 1 ' From image coordinates (pixels) to camera cordinates (mm) p_x = (-e_ * c_ + e_ * x + f_ * b_ - y * b_) / (a_ * e_ - b_ * d_) p_y = -(a_ * f_ - a_ * y - c_ * d_ + x * d_) / (a_ * e_ - b_ * d_) End Select End Sub Public Function det_cal3(ByRef E() As Double) As Double ' This function calculates the determinant of a 3x3 matrix E Dim term1 As Double, term2 As Double, term3 As Double, term4 As Double, term5 As Double, term6 As Double term1 = E(1, 1) * E(2, 2) * E(3, 3) term2 = E(2, 1) * E(3, 2) * E(1, 3) term3 = E(3, 1) * E(1, 2) * E(2, 3) term4 = E(1, 1) * E(3, 2) * E(2, 3) term5 = E(2, 1) * E(1, 2) * E(3, 3) term6 = E(3, 1) * E(2, 2) * E(1, 3) det_cal3 = term1 + term2 + term3 - term4 - term5 - term6 End Function