MicroStation is a 3D design tool.
It lets you model objects in a 3D space, and also works in 2D.
Often, we want to model an object and then rotate it.
In these articles, we discuss rotation in 2D and 3D using a VBA Matrix3d
.
When dealing with matrices, the identity matrix is often useful.
The
identity matrix
is a no-op matrix.
When you multiply any matrix with an identity matrix, the result is the same as the original matrix.
It means 'no rotation'.
In MicroStation VBA, function Matrix3dIdentity
returns an identity matrix.
This code gets the result of multiplying an angle by the identity matrix:
it's the same as adding zero degrees to an angle expressed in degrees or radians …
Const angle1 As Double = 30 ' degrees
Dim r1 As Double
r1 = Radians(angle1)
Dim m1 As Matrix3d
Dim m2 As Matrix3d
Const ZAxis As Long = 2
m1 = Matrix3dFromAxisAndRotationAngle(ZAxis, r1)
m2 = Matrix3dIdentity
Dim multiplication As Matrix3d
multiplication = Matrix3dFromMatrix3dTimesMatrix3d(m1, m2)
Dim result As Double
If Matrix3dIsXYRotation(multiplication, result) Then
Debug.Print "30 * Identity Matrix=" & Degrees(result)
Else
Debug.Print "Matrix has skew, scale or mirror"
End If
A matrix having all components equal to zero (VBA Matrix3dZero
) is useless for calculating rotation.
It doesn't represent 'no rotation'.
Don't use it!
It exists because matrix arithmetic can be used for many things besides rotation. Matrices are often used in science, engineering and statistics, where a zero matrix can be useful. For instance, to specify an initial condition prior to some accumulative calculation.
Post questions about MicroStation programming to the MicroStation Programming Forum.