Regarding the basic concepts of AcGeMatrix3d and simple methods of implementing COPY and MOVE, see the post:
https://www.theswamp.org/index.php?topic=58880.msg617740#msg617740ARX constructs the rotation transformation matrix through AcGeMatrix3d::setToScaling(..)
======================
Let’s enter the content of high-order points, matrix combination transformation, take the ALIGN command as an example,
As shown below, an ALIGN operation is a combination of translation, rotation, and scaling.
we want:
1. Translate first
2. Then rotate and align
3. Zoom and stretch
It requires three transformations,
result:
(and (setq ss
(xdrx
-ssget "\nSelect the object to be Aligned <exit>:")) )
(xdrx-begin)
)
mat-rot (xdrx-matrix-setrotation
'(0 0 1.0)
dest-p1
)
mat-scl (xdrx-matrix-setscale
)
dest-p1
)
)
(setq ents
(xdrx
-ss
->ents ss
)) (xdrx
-entity
-transform ents mat
-trans); first translation (xdrx-entity-transform ents mat-rot); second rotation align
(xdrx-entity-transform ents mat-scl); third scale stretch
(xdrx-end)
)
)
)
If a complex transformation is carried out dozens of times, then it will be transformed to the final result one at a time. Isn't it very inefficient because AUTOCAD needs to refresh the object, display, etc. every time it transforms?
Is there any way to transform to the final result in one go?
have:
This is the artifact of mathematics, matrix combination transformation,
Use matrix left multiplication to obtain the final transformation matrix in one go.
The order of left multiplication is that the last transformation is at the front and the first matrix operation is at the end.
The ARX AcGeMatrix3d class provides AcGeMatrix3d::setToProduct(...)
==========
The following code uses a combination matrix to find the align transformation matrix. Only one transform operation is used to obtain the final transformation result.
(and (setq ss
(xdrx
-ssget "\nSelect the object to be Aligned <exit>:")) )
(xdrx-begin)
)
mat-rot (xdrx-matrix-setrotation
'(0 0 1.0)
dest-p1
)
mat-scl (xdrx-matrix-setscale
)
dest-p1
)
mat
-align
(xdrx
-matrix
-product mat
-scl mat
-rot mat
-trans) )
(setq ents
(xdrx
-ss
->ents ss
)) (xdrx-entity-transform ents mat-align)
(xdrx-end)
)
)
)