本帖最后由 飞雪神光 于 2023-6-2 00:54 编辑
这个是矩阵的方法
- (defun BF-Mat-ApplyMatrixTransformation (target matrix vector)
- (cond
- ((eq 'VLA-OBJECT (type target))
- (vla-TransformBy target
- (vlax-tMatrix
- (append (mapcar (function (lambda (x v) (append x (list v)))) matrix vector)
- '((0. 0. 0. 1.))
- )
- )
- )
- )
- ((listp target)
- (mapcar
- (function
- (lambda (point) (mapcar '+ (BF-Mat-MxV matrix point) vector))
- )
- target
- )
- )
- )
- )
- (defun BF-Mat-MxV (m v)
- (mapcar (function (lambda (r) (apply '+ (mapcar '* r v)))) m)
- )
- (defun BF-Mat-ReflectByMatrix (target p1 p2 / m)
- (
- (lambda ( a / m )
- (BF-Mat-ApplyMatrixTransformation target
- (setq m
- (list
- (list (cos a) (sin a) 0.)
- (list (sin a) (- (cos a)) 0.)
- (list 0. 0. 1.)
- )
- )
- (mapcar '- p1 (BF-Mat-MxV m p1))
- )
- )
- (* 2. (angle p1 p2))
- )
- )
- (BF-Mat-ReflectByMatrix (vlax-ename->vla-object(car(entsel))) (getpoint) (getpoint))
|