;; Pick an angle by three points and choose the number of parts you want to divide the
;; angle into.Lines are drawn from the vertex dividing the angle.
;; Created by Lee Mak
;; Saved from: https://www.theswamp.org/index.php?action=post;quote=487487;topic=43500.0

(defun c:ad ( / a d n p q s v x )
(if (and
(setq v (getpoint "\nPick Angle Vertex: "))
(setq p (getpoint v "\nPick 1st Endpoint: "))
(setq q (getpoint v "\nPick 2nd Endpoint: "))
)
(progn
(initget 6)
(if (null (setq n (getint "\nSpecify Number of Divisions : ")))
(setq n 2)
)
(if (not (LM:Clockwise-p p v q))
(setq x p p q q x)
)
(setq a (/ (LM:GetInsideAngle p v q) n)
s (+ a (angle v p))
d (max (distance v p) (distance v q))
)
(repeat (1- n)
(entmake (list '(0 . "LINE") (cons 10 (trans v 1 0)) (cons 11 (trans (polar v s d) 1 0))))
(setq s (+ s a))
)
)
)
(princ)
)

;; Get Inside Angle - Lee Mac
;; Returns the smaller angle subtended by three points with vertex at p2

(defun LM:GetInsideAngle ( p1 p2 p3 )
( (lambda ( a ) (min a (- (+ pi pi) a)))
(rem (+ pi pi (- (angle p2 p1) (angle p2 p3))) (+ pi pi))
)
)

;; Clockwise-p - Lee Mac
;; Returns T if p1,p2,p3 are clockwise oriented

(defun LM:Clockwise-p ( p1 p2 p3 )
(< (* (- (car p2) (car p1)) (- (cadr p3) (cadr p1)))
(* (- (cadr p2) (cadr p1)) (- (car p3) (car p1)))
)
)

(c:ad)

Advertisements