jw_cad 外部変形 - (496) clispで円を描く -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

clispで円を描く

:clispで円を描く
@echo off
if not exist %~dpn0.lisp (
  for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
    more +%%n %0 > %~dpn0.lisp
  )
)
clisp %~dpn0.lisp
goto:eof

REM #jww
REM #1-%d 円の中心を指示してください
REM #2%d 円周上の点を指示してください
REM #e

#!この次の行からプログラムを書いてください
(defmacro while (test &body body)
  `(do ()
   ( (not ,test) )
   ,@body)
)
(with-open-file (f "jwc_temp.txt" :direction :input)
  (while (setq line (read-line f nil))
    (setq a (regexp:regexp-split "\\s\\+" line))
    (if (regexp:match "^hp1" line) (setq hp1 a) nil)
    (if (regexp:match "^hp2" line) (setq hp2 a) nil)
  )
  (close f)
)
(setq x1 (read-from-string (nth 1 hp1)))
(setq y1 (read-from-string (nth 2 hp1)))
(setq x2 (read-from-string (nth 1 hp2)))
(setq y2 (read-from-string (nth 2 hp2)))
(setq r (sqrt (+ (* (- x2 x1) (- x2 x1)) (* (- y2 y1) (- y2 y1)))))
(with-open-file (f "jwc_temp.txt" :direction :output)
  (write-line (format nil "ci ~A ~A ~A" x1 y1 r) f)
  (close f)
)