550 likes | 567 Views
TRANSFORMATIONS. Transformations. What is this section going to cover? Different types of Transformations Implementation of Transformations in MicroStation Constructing Transformation Matrices The Current Transform. What are Transformations ?.
E N D
Transformations What is this section going to cover? • Different types of Transformations • Implementation of Transformations in MicroStation • Constructing Transformation Matrices • The Current Transform
What are Transformations? • Analytical equations to manipulate points or elements in 3D space • Stored in matrix form • Used for generating or modifying elements, displaying dynamics, or orientating views
Types of Transformations • Translation • Scaling • Rotation • Other...
Types of Transformations Translation
Types of Transformations Translation - Matrix Form
Types of Transformations Notes on Matrix Form: • MicroStation’s convention • The fourth row in the matrix is introduced to make the matrix square • Fourth row results in 1 = 1
Types of Transformations Scaling
Types of Transformations Scaling - Matrix Form
Types of Transformations Rotation about the Z-axis
Types of Transformations Rotation about Z - Matrix Form
Types of Transformations Notes on Rotation • Stored separately in MicroStation in a 3x3 matrix • We’ve seen only rotation about the Z-axis • Values in the 3x3 matrix can represent angles about all three axi • Usually only need to deal with rotation about the Z-axis when constructing matrices
Types of Transformations Mirroring
Types of Transformations Shearing
Types of Transformations Matrix Summary • Visualize an element transformation as the result of all points on the element being manipulated by the transformation matrix • Composite transformations will be discussed later...
MDL Transformation Matrices How MicroStation stores Matrices • Transform union holds a 3 x 4 matrix for 3D files or a 2 x 3 matrix for 2D files • RotMatrix union holds a 3 x 3 matrix for 3D files or a 2 x 2 matrix for a 2D files • MDL functions will access the appropriate matrix in the union
MDL Transformation Matrices • Transform matrix can have all elements of translation, scaling, and rotation • Represents a complete transformation in 3D space • RotMatrix can hold both rotation and scaling • A rotation matrix consisting of pure rotation is an orthogonal matrix
MDL Transformation Matrices What is an orthogonal matrix? • By definition, a matrix is orthogonal if its transpose is equal to its inverse • Thus, the transpose of the matrix multiplied by the original matrix will equal the identity matrix
MDL Transformation Matrices What is the identity matrix? • a square matrix consisting of zeros with unity along the diagonal • represents no change to points or elements manipulated by it
MDL Transformation Matrices Proof:
MDL Transformation Matrices Benefits of an orthogonal matrix • Points that are transformed by an orthogonal matrix can be returned to their original state by transforming the resulting points by the transpose of the original matrix • Transposition is not computationally intensive compared to full matrix inversion
MDL Transformation Matrices Orthogonal rotation matrices • Stored with cells, arcs, text, etc. representing 3D rotation from an unrotated definition • Elements can be rotated back to their unrotated orientation by applying the transpose of the element’s rotation matrix
MDL Transformation Matrices View rotation matrices • MicroStation also stores a RotMatrix on each view defining its orientation or viewing plane • Design file elements are transformed by the view rotation matrix for display on screen • mdlRMatrix_fromView
MDL Transformation Matrices View rotation matrix • Represents a rotation from the World coordinate system to the View coordinate system • An element flat to a view will obtain a plan view orientation when physically transformed by the view’s rotation matrix • The transpose of the view rotation matrix is required to physically rotate elements from a world orientation to the view
MDL Transformation Matrices Standard view rotation matrices
MDL Functions • Functions are available to construct matrices and manipulate points or elements • Operate on RotMatrix, Transform, MSElement, and MSElementDesr • Of the form mdlRMatrix_… and mdlTMatrix_…
MDL Functions • mdlRMatrix_getIdentity • mdlRMatrix_invert • mdlRMatrix_getinverse • mdlRMatrix_normalize
MDL Functions • mdlRMatrix_fromView • mdlRMatrix_from3Points • mdlRMatrix_fromAngle • mdlRMatrix_rotate
MDL Functions • mdlRMatrix_rotatePoint • mdlRMatrix_rotatePointArray • mdlRMatrix_unrotatePoint • mdlRMatrix_unrotatePointArray
MDL Functions • mdlRMatrix_fromTMatrix • mdlTMatrix_fromRMatrix
MDL Functions • mdlTMatrix_getIdentity • mdlTMatrix_setTranslation • mdlTMatrix_scale • mdlTMatrix_rotateByAngles
MDL Functions • mdlTMatrix_transformPoint • mdlTMatrix_transformPointArray • mdlTMatrix_rotateScalePoint
MDL Functions • mdlTMatrix_referenceToMaster • mdlTMatrix_masterToReference
MDL Functions • mdlElement_transform • mdlElmdscr_transform
Multiple Transformations • A complete element transformation may require scaling, rotation, and translation • Rotation and scaling is usually relative to a fixed point on the element • This would require translation of the element so that the fixed point resides at 0,0,0
Multiple Transformations EXAMPLE: Rotating a cell about its origin
Multiple Transformations STEP 1:Translation to the global origin
Multiple Transformations: STEP 2: Rotation about the global origin
Multiple Transformations STEP 3: Translation back to point in space
Multiple Transformations Transformations can be applied in succession.. mdlTMatrix_getIdentity(&tMatrix); mdlTMatrix_setTranslation(&tMatrix, &transTo); mdlElmdscr_transform(edP, &tMatrix); mdlTMatrix_getIdentity(&tMatrix); mdlTMatrix_rotateByAngles(&tMatrix, &tMatrix, fc_zero, fc_zero, angle_rad); mdlElmdscr_transform(edP, &tMatrix); mdlTMatrix_getIdentity(&tMatrix); mdlTMatrix_setTranslation(&tMatrix, &transBack); mdlElmdscr_transform(edP, &tMatrix);
Multiple Transformations …or concatenated into a composite matrix • There exists a single matrix representing a complete transformation • Multiplying the individual matrices will result in the composite matrix
Multiple Transformations EXAMPLE: Order of Transformations
Multiple Transformations MicroStation’s matrix convention requires the matrices to be multiplied in reverse order
Multiple Transformations • Matrix multiplication is associative but not commutative • Any two adjacent matrices can be multiplied together • Must adhere to reverse order of multiplication
Multiple Transformations EXAMPLE: The Composite Transformation Matrix
Composite Transformations • MDL functions accepting an input matrix usually construct a composite transformation matrix • Passing NULL will initialize the input matrix to the identity matrix • But difficult to predict the order in which matrices are multiplied
Composite Transformations Can explicitly multiply individual matrices... • mdlRMatrix_multiply • mdlTMatrix_multiply
Composite Transformations EXAMPLE: Explicit Matrix Multiplication mdlTMatrix_translate(&tMatrixTo, NULL, -origin.x, -origin.y, -origin.z) mdlTMatrix_rotateByAngles(&tMatixRot, NULL, fc_zero, fc_zero, angle_rad) mdlTMatrix_translate(&tMatrixBack, NULL, origin.x, origin.y, origin.z) mdlTMatrix_multiply(&tMatrixTmp, &tMatrixBack, &tMatrixRot) mdlTMatrix_multiply(&tMatrix, &tMatrixTmp, &tMatrixTo) mdlElmdscr_transform(edP, &tMatix)
Composite Transformations …or use the functions that accept an input matrix mdlTMatrix_rotateByAngles(&tMatrix, NULL, fc_zero, fc_zero, angle_rad); mdlTMatrix_setOrigin (&tMatrix, &origin); mdlElmdscr_transform (edP, &tMatrix);
Transformations Summary • In constructing transformation matrices first list the required individual transformations • Adhere to the rules of matrix multiplication and convention • Implement MDL functions conveniently