本帖最后由 xyp1964 于 2018-5-17 22:22 编辑
;; 横平竖直及对角线的都简单- ;; xyp-MkPat (xyp-MkPat 基点 起点 终点 单元宽度 单元高度);; delta-x:x轴位移;delta-y:y轴位移;dash-1画线长;dash-2空移长
- (defun xyp-MkPat (p0 p1 p2 dx dy / rad ang ang0 ang01 ll dash-1 dash-2 x-origin y-origin dash-2 delta-x delta-y delta-y1)
- (setq rad (angle p1 p2)
- ang (xyp-r2d rad)
- lst (list p1 p2)
- )
- (if (and (>= ang 180) (not (equal ang 360 1e-5)))
- (setq p2 (car lst)
- p1 (cadr lst)
- )
- )
- (setq p0 (xyp-3d2d p0)
- p1 (xyp-3d2d p1)
- p2 (xyp-3d2d p2)
- p1 (mapcar '- p1 p0)
- p2 (mapcar '- p2 p0)
- rad (angle p1 p2)
- ang (xyp-r2d rad) ; 角度
- dash-1 (distance p1 p2) ; 线长
- r0 (angle '(0 0) (list dx dy))
- ang0 (xyp-r2d r0) ; 矩形对角线角度
- ang01 (angle '(0 0) (list (- dx) dy))
- ll (distance '(0 0) (list dx dy)) ; 矩形对角线长度
- x-origin (car p1)
- y-origin (cadr p1)
- dash-2 (- dash-1 ll)
- delta-x (* dx (cos r0))
- delta-y (* dx (sin r0))
- delta-y1 (- delta-y)
- )
- (cond ((equal y-origin (cadr p2) 1e-5) ;水平方向
- (list ang x-origin y-origin dx dy dash-1 (- dash-1 dx))
- )
- ((equal x-origin (car p2) 1e-5) ; 垂直方向
- (list ang x-origin y-origin dy dx dash-1 (- dash-1 dy))
- )
- ((equal ang ang0 1e-5) ;对角线方向(第1象限)
- (list ang x-origin y-origin delta-x delta-y1 dash-1 dash-2)
- )
- ((equal rad ang01 1e-5) ; 对角线方向(第2象限)
- (list ang x-origin y-origin delta-x delta-y dash-1 dash-2)
- )
- (t (xyp-PattenCal p1 p2 dx dy)) ;★ 其它方向,这个是难度之处★
- )
- )
|