Author Topic: [AcGe(7)] AcGeMatrix3d - Matrix operation application examples(3)-Rotate  (Read 380 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 514
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#msg617740

ARX constructs the rotation transformation matrix through AcGeMatrix3d::setToRotation(..)



======================

Use the rotate transformation matrix under AcGeMatrix3d and cooperate with the point monitor to implement the original AUTOCAD rotate command:



Code - Auto/Visual Lisp: [Select]
  1. (defun c:rot ()
  2.   (defun _call-back (dynpt)
  3.     (xdrx-entity-delete clone)
  4.     (setq mat-rotate
  5.            (xdrx-matrix-setrotation (angle base dynpt) '(0 0 1) base)
  6.     )
  7.     (setq clone (xdrx-entity-transformedcopy ents mat-rotate))
  8.   )
  9.   (if
  10.     (and (setq ss (xdrx-ssget "\nSelect the object to be moved <exit>:"))
  11.          (setq p1 (getpoint "\nThe first point of the rot base<exit>:"))
  12.     )
  13.      (progn
  14.        (xdrx-begin)
  15.        (setq ents  (xdrx-ss->ents ss)
  16.              clone (xdrx-entity-copy ss)
  17.        )
  18.        (setq base p1)
  19.        (xdrx-pointmonitor "_call-back")
  20.        (if (setq p2 (getpoint p1 "\nRotation axis Second point <Exit>:"))
  21.          (progn
  22.            (if (and (xdrx-initget "Y N")
  23.                     (= 0
  24.                        (xdrx-yesorno
  25.                          "\nWhether to keep the original object:"
  26.                          1
  27.                        )
  28.                     )
  29.                )
  30.              (xdrx-entity-delete ents)
  31.            )
  32.          )
  33.        )
  34.        (xdrx-pointmonitor)
  35.        (xdrx-end)
  36.      )
  37.   )
  38.   (princ)
  39. )
« Last Edit: December 12, 2023, 02:46:38 AM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net