I'm trying to make a list of 3d coordinates of a sphere vertices, starting with ((0 0 1) ...) like this:
(defvar spherelatamount 7)
(defvar spherelonamount 8)
(defparameter sphereverticeslist
(make-list (+ 2 (* (- spherelatamount 2) spherelonamount))))
(setf (elt sphereverticeslist 0) '(0 0 1))
Trying to add next point
(setf (elt sphereverticeslist 1)
'(0 (sin (/ pi 6)) (cos (/ pi 6))))
this gives result
((0 0 1) (sin (/ pi 6)) (cos (/ pi 6)) ...)
while I need:
((0 0 1) (0 0.5 0.866) ...)
i.e. evaluated sin and cos. How do I achieve that? Thanks.
wrote:
(defvar spherelatamount 7)
(defvar spherelonamount 8)
(defparameter sphereverticeslist
(make-list (+ 2 (* (- spherelatamount 2) spherelonamount))))
(setf (elt sphereverticeslist 0)
'(0 0 1))
(setf (elt sphereverticeslist 1)
'(0 (sin (/ pi 6)) (cos (/ pi 6))))
expecting:
((0 0 1) (0 0.5 0.866) ...)
Quoting the list prevents evaluation of everything in the list, so you just insert the literal values.
Call list
to create a list with evaluated values.
(setf (elt sphereverticeslist 1) (list 0 (sin (/ pi 6)) (cos (/ pi 6))))
If you have a mixture of literal and evaluated values, you can use backquote/comma.
(setf (elt sphereverticeslist 1) `(0 ,(sin (/ pi 6)) ,(cos (/ pi 6))))