x-point y-point z-point
size spacing loops totallength
runoffsetdist runlengthdist
runstartpoint runendpoint
cntr lst)
;; Adds a distance to a point unless a point equals zero.
;; This is to keep from altering the z-value. If either of the x or
;; y coords were actually zero, the routine will not work properly.
(+ dist
(list direction x1
))) )
pt1))
;; Draws a polyline for a given list of points.
(defun drawpolyline
(lst
)
;; Determine if a number is odd.
;; Name for x point.
;; Name for y point.
;; Name for z point.
;; Get some points
(princ "\nPick points left to right.")
;; Calculate the rectangular size.
(setq size
(mapcar '
- pt1 pt2
) ; -Determine the size of the rectangle. size
(mapcar '
abs size
) ; -make numbers positive ; (in case user picked from right to left).
)
;; Determine the number of spacing and loops
loops (/
(- (y-point size) (* spacing 1.5))
(* spacing 2)) ; -Calculate the number of loops to draw.
loops (roundit loops) ; -round the loop count up/down
totallength ; -Used for reporting.
(/ (* (* loops 2) (x-point size)) 12)
)
;; Print some numbers for the user's information.
;; Calculate some initial points and distances.
;;
;; XXX:
;; 1. Center the loops vertically.
;; 1a. Center the loops horizontally.
;; ~ Blindly adding a distance to to the `runstartpoint`
;; will "center" vertically but cause inaccurate
;; `runlengthdist` and thus cause the loops to be
;; not centered horizontally.
;; TODO:
;; 1. Handle vertical and horizontal drawing.
;; ~ This may require building an association list--for each
;; orientation--to store the values. The list(s) can then
;; be referenced later when/if user is offered a choice
;; between the two orientations.
;; Something like:
;; (list
;; ;; 1 - size
;; ;; 2 - number of loops
;; ;; 3 - total length
;; ;; 4 - spacing
;; ;; 5 - point list
;; (cons 0 (list pt1 pt2))
;; (cons 1 (list size))
;; (cons 2 loops)
;; (cons 3 totallength)
;; (cons 4 spacing)
;; (cons 5 lst) )
;; (drawpolyline (cadr (assoc 5 <looplist>)))
(+ (x-point pt1) spacing)
(+ (y-point pt1)
(/
(* loops
(* spacing 2))
loops)) ; -Find distance we need (from the bottom)
(z-point pt1)) ; to center the layout.
runoffsetdist (* spacing 1.5)
runlengthdist (- (x-point size) runoffsetdist runoffsetdist)
runendpoint
(polar runstartpoint
0 runlengthdist
) cntr 1
lst
(list runendpoint runstartpoint
) ; -This will be the first loop ; (the bottom most) to draw.
)
;; Calculate the points working from the bottom upwards to the top.
;; This is where we generate the remaining points of the center
;; line.
;;
;; TODO:
;; 1. See TODO note #1 above.
(polar x
1.5708 (* (* spacing
2) cntr
)) lst)))
(list runendpoint runstartpoint
) (list runstartpoint runendpoint
) )
)
)
(drawpolyline lst)
)