- ;; xyp-Div3DistWith2Pt 沿两点3种距离等分的最优组合 (xyp-Div3DistWith2Pt p1起点 p2终点 d1距离1 d2距离2 d3距离3)
- ;; 返回(n1距离1的数量 n2距离2的数量 n3距离3的数量 dl剩余长度)
- ;; (xyp-Div3DistWith2Pt '(0 0) '(3761.59 0) 1000 500 300) → (3 0 2 161.59)
- (defun xyp-Div3DistWith2Pt (p1 p2 d1 d2 d3 / a l1 l2 l3 ll lst n1 n2 n3)
- (setq ll (distance p1 p2)
- lst '()
- n1 (fix (/ ll d1 1.))
- l1 (- ll (* n1 d1))
- n2 (fix (/ l1 d2 1.))
- l2 (- l1 (* n2 d2))
- n3 (fix (/ l2 d3 1.))
- l3 (- l2 (* n3 d3))
- a (list n1 n2 n3 l3)
- lst (cons a lst)
- n2 (1- n2)
- n2 (if (< n2 0)
- 0
- n2
- )
- l2 (- ll (* d1 n1) (* d2 n2))
- n3 (fix (/ l2 d3 1.))
- l3 (- l2 (* n3 d3))
- a (list n1 n2 n3 l3)
- lst (cons a lst)
- n1 (1- n1)
- n1 (if (< n1 0)
- 0
- n1
- )
- l1 (- ll (* n1 d1))
- n2 (fix (/ l1 d2 1.))
- l2 (- l1 (* n2 d2))
- n3 (fix (/ l2 d3 1.))
- l3 (- l2 (* n3 d3))
- a (list n1 n2 n3 l3)
- lst (cons a lst)
- n2 (1- n2)
- n2 (if (< n2 0)
- 0
- n2
- )
- l2 (- ll (* d1 n1) (* d2 n2))
- n3 (fix (/ l2 d3 1.))
- l3 (- l2 (* n3 d3))
- a (list n1 n2 n3 l3)
- lst (cons a lst)
- lst (vl-sort lst
- '(lambda (x y)
- (cond ((< (last x) (last y)) t)
- ((and (> (car x) (car y)) (= (last x) (last y))) t)
- )
- )
- )
- )
- (car lst)
- )
|