2018年9月30日 星期日

LISP 練習 5TEST3

=================================

(defun c:5test3()
  ;FileName:5test3_ex.LSP
  (setq baspt (getpoint "請輸入左下角:"))
  (setq a (getreal "\n 請輸入A邊長:"))
  (setq b (getreal "\n 請輸入B邊長:"))
  (setq c (getreal "\n 請輸入C邊長:"))
  (setq bs (/ (+ a b c) 2))
  ;S=(A+B+C)/2
  (setq ba (sqrt (* bs (- bs a) (- bs b) (- bs c))))
  ;AREA=sqr(S(S-A)(S-B)(S-C))
  (setq h (/ (* 2 ba) a))
  ;AREA=a*h/2 ==> h=AREA*2/a2
  ;(princ "h=")(princ h)
  (setq a1 (sqrt (- (* c c) (* h h))))
  ;(princ "\n a1=")(princ a1)
  (setq a2 (sqrt (- (* b b) (* h h))))
  ;(princ "\n a2=")(princ a2)
  (setq pt1 (polar baspt 0 a))
  (setq ang1 (atan (/ h a1)))
  (setq ang1a (* ang1 (/ 180 pi)))
  ;(princ "\n ang1a = ")(princ ang1a)
  (setq pt2 (polar baspt ang1 c))
  (command "pline" baspt pt2 pt1 "c")
  (prin1)
)
  (prompt "\n <<5test3 by Hsiao C.C. >>")
  (prin1)

沒有留言:

張貼留言