- ;;;-----------------------------------------------------------;;
- ;;; 二维镜像变换矩阵 ;;
- ;;; 参数: ;;
- ;;; p1 - 镜像向量第一点 ;;
- ;;; p2 - 镜像向量第二点 ;;
- ;;;-----------------------------------------------------------;;
- ;;;----------------=={ Reflect by Matrix }==------------------;;
- ;;; ;;
- ;;; Reflects a VLA-Object or Point List using a ;;
- ;;; Transformation Matrix ;;
- ;;;-----------------------------------------------------------;;
- ;;; Author: Lee Mac, Copyright ? 2010 - www.lee-mac.com ;;
- ;;;-----------------------------------------------------------;;
- ;;; Arguments: ;;
- ;;; target - VLA-Object or Point List to transform ;;
- ;;; p1, p2 - Points representing vector in which to reflect ;;
- ;;;-----------------------------------------------------------;;
- (defun MAT:Reflect ( p1 p2 / a c s x y)
- (setq a (angle p1 p2) a (+ a a))
- (setq c (cos a) s (sin a))
- (setq x (car p1) y (cadr p1))
- (list
- (list c s 0. (- x (+ (* c x) (* s y))))
- (list s (- c) 0. (- y (- (* s x) (* c y))))
- '(0. 0. 1. 0.)
- '(0. 0. 0. 1.)
- )
- )
- (defun c:tt ()
- (setq ss (ssget) ;选择集镜像
- pt1 (getpoint)
- pt2 (getpoint pt1)
- i 0
- mat (mat:reflect pt1 pt2)
- )
- (repeat (sslength ss)
- (setq e (ssname ss i)
- obj (vla-copy (vlax-ename->vla-object e))
- i (1+ i)
- )
- ;;; (vla-Mirror obj (vlax-3D-point pt1)(vlax-3D-point pt2))
- (vla-transformby obj (vlax-tmatrix mat))
- )
- )
这个看着简单, 速度上没啥优势 |