terryyang516 发表于 2014-7-26 12:36:23

直線思路尋求解答

各位大神
想請教思路如何做到下列情形




簡單說我想要藉由使用者取得兩點 (basepointX, basepointY)
再取得使用者想要的寬度(width)
不管形成的角度如何都保持四角都是90度
但實際情形我卻做成了右邊的情況
估計是我搞錯了角度旋轉的問題
有請大神協助!

edata 发表于 2014-7-26 13:38:19

(defun c:tt(/ BasePtX BasePtY width ang1 offsetx1 offsetx2 offsety1 offsety2)
(if(and(setq BasePtX(getpoint "BasePtX: "))
       (setq BasePtY(getpoint BasePtX "BasePtY: "))
       )
    (progn
      (setq width (cond((getdist "Enter width<10>: " ))(10)))
      (setq ang1(angle BasePtX BasePtY))
      (setq offsetx1(polar BasePtX (+ ang1(* pi 0.5)) (* width 0.5))
          offsetx2(polar BasePtX (+ ang1(* pi 1.5)) (* width 0.5))
          offsety1(polar BasePtY (+ ang1(* pi 1.5)) (* width 0.5))
          offsety2(polar BasePtY (+ ang1(* pi 0.5)) (* width 0.5))
          )
      (command "pline" "non" offsetx1 "non" offsetx2 "non" offsety1 "non" offsety2 "c")
      )
    )
(princ)
)

terryyang516 发表于 2014-7-26 13:41:13

edata 发表于 2014-7-26 13:38 static/image/common/back.gif


謝謝e神!
馬上茅塞頓開!
页: [1]
查看完整版本: 直線思路尋求解答