Guest User

Untitled

a guest
Sep 9th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.15 KB | None | 0 0
  1. ; sp - список координат
  2. (defun chas (sp / ang_sum ch lsp ang_sum1 n)
  3.  
  4.   (setq ang_sum 0)
  5.   (setq ch 0)
  6.   (setq lsp (length sp))
  7.   ; m_ang(1,2,3) - угол между отрезками 12, 23 с вершиной в 2
  8.   ; ang_sum = ang_sum + m_ang (sp[last], sp[ch], sp[ch+1] )
  9.   (setq ang_sum (+ ang_sum (m_ang (nth (1- lsp) sp) (nth ch sp) (nth (1+ ch) sp) )))
  10.   (setq ch (1+ ch))
  11.  
  12.   ; for (int i = 0; i < sp.Length - 2; i++)
  13.   ; {
  14.   ;     ang_sum = ang_sum + m_ang(sp[last],sp[ch],sh[ch+1]
  15.   ;     ch++
  16.   ; }
  17.  
  18.   (repeat (- lsp 2)
  19.     (progn
  20.       ; ang_sum += m_ang(sp[ch-1] sp[ch] sp[ch+1)
  21.       (setq ang_sum (+ ang_sum (m_ang (nth (1- ch) sp) (nth ch sp) (nth (1+ ch) sp))))
  22.       (setq ch (1+ ch))
  23.     )
  24.   )
  25.   ; ang_sum += m_ang(sp[ch-1] sp[ch] sp[0])
  26.   (setq ang_sum (+ ang_sum (m_ang (nth (1- ch) sp) (nth ch sp)  (nth 0 sp) )))
  27.  
  28.   ; ang_sum1 = sp.Length * PI - 2 * PI
  29.   (setq ang_sum1 (- (* lsp pi) (* pi 2)))
  30.  
  31.   ; return ((Math.Abs(ang_sum - ang_sum1) <= 0.1) || (ang_sum < ang_sum1) )
  32.   (setq n (or (equal ang_sum ang_sum1 0.1) (< ang_sum ang_sum1 ) ))
  33. ;  (if (not n) (alert "not chas") (alert "chas") )
  34.   (setq n n)
  35. )
Add Comment
Please, Sign In to add comment