jiangjun 发表于 2011-6-28 15:23:40

谁帮我看看这个小程序

本帖最后由 jiangjun 于 2011-6-28 15:26 编辑

问题:当ZFH为左时得到pp2点是错误的,pp2方向角度没有问题 距离出错。
(defun C:dl()
(setq r 200)
(setq pt1(getpoint"第一点:>>"))
(setq pt2(getpoint"第二点:>>"))
(setq pt3(getpoint"第三点:>>"))
(setq p1(angle pt1 pt2))
(setq p2(angle pt3 pt2))
(jdzf)
(setq tt(* r(/(sin(/ jd 2))(cos(/ jd 2)))));切线长度
(setq fc(* r jd));弧长
(setq e(* r(-(/ 1(cos(/ jd 2)))1)));外矩距
(setq d1(distance pt1 pt2))
(setq d2(distance pt3 pt2))
(setq pp1(polar pt2 (angle pt2 pt1)tt))
(setq pp3(polar pt2 (angle pt2 pt3) tt))
(if(= zfh "左")
    (setq pp2(polar pt2 (- p2 (/ (- pi jd)2))(* r(-(/ 1(cos(/ jd 2)))1))))
    )
(if(= zfh "右")
    (setq pp2(polar pt2 (+ p1 (/ (- pi jd)2)) (- 0 e)))
    )
(command "arc" pp1 pp2 pp3 "")
)
(defun jdzf()
(setq x1(car pt1)
y1(cadr pt1)
x2(car pt2)
y2(cadr pt2)
x3(car pt3)
y3(cadr pt3))
(if(and(> y1 y2)(> y3 y2)(< x1 x2)(> x3 x2))
    (setq zfh "左"))
(if(and(< y1 y2)(< y3 y2)(< x1 x2)(> x3 x2))
    (setq zfh "右"))
(if(and(> y1 y2)(< y3 y2)(< x1 x2)(< x3 x2))
    (setq zfh "右"))
(if(and(> y1 y2)(< y3 y2)(> x1 x2)(> x3 x2))
    (setq zfh "左"))
(if(and(> y1 y2)(< y3 y2)(= x1 x2)(< x3 x2))
    (setq zfh "右"))
(if(and(> y1 y2)(< y3 y2)(= x1 x2)(> x3 x2))
    (setq zfh "左"))
(if(and(< y1 y2)(> y3 y2)(< x1 x2)(= x3 x2))
    (setq zfh "左"))
(if(and(< y1 y2)(> y3 y2)(> x1 x2)(= x3 x2))
    (setq zfh "右"))
(if(and(= y1 y2)(< y3 y2)(< x1 x2)(> x3 x2))
    (setq zfh "右"))
(if(and(= y1 y2)(> y3 y2)(< x1 x2)(> x3 x2))
    (setq zfh "左"))
(if(and(< y1 y2)(= y3 y2)(> x1 x2)(< x3 x2))
    (setq zfh "左"))
(if(and(> y1 y2)(= y3 y2)(> x1 x2)(< x3 x2))
    (setq zfh "右"))
(if(= zfh "左")
(setq jd(- pi(- p1 p2)))
)
(if(= zfh "右")
(setq jd(- pi(- p2 p1)))
)
)

ZZXXQQ 发表于 2011-6-28 21:03:53

要那么复杂干啥
(defun C:dl ()
(setq r 200)
(setq pt1 (getpoint "\n第一点 :>>"))
(setq pt2 (getpoint "\n第二点 :>>"))
(setq pt3 (getpoint "\n第三点 :>>"))
(command ".LINE" pt1 pt2 pt3 "")
(command ".FILLET" "r" r ".FILLET" pt1 pt3)
(princ)
)

jiangjun 发表于 2011-6-29 09:06:19

页: [1]
查看完整版本: 谁帮我看看这个小程序