任意の三点を通る平面を描くソースコード
(defun draw-plane (p1 p2 p3)
(let ((v1 (make-vector 3))
(v2 (make-vector 3)))
(dotimes (i 3)
(aset v1 i (- (aref p2 i) (aref p1 i)))
(aset v2 i (- (aref p3 i) (aref p1 i))))
(let ((normal (make-vector 3)))
(dotimes (i 3)
(aset normal i
(+ (* (aref v1 (+ (% i 3) 1)) (aref v2 (+ (% i 3) 2)))
(* (aref v1 (+ (% i 3) 2)) (aref v2 (+ (% i 3) 1))))))
(let ((d (dot-product p1 normal)))
(glBegin GL_LINES)
(dotimes (i (- (length *plane-grid*) 2))
(let ((t1 (* i (/ 1.0 (- (length *plane-grid*) 2))))
(t2 (* (+ i 1) (/ 1.0 (- (length *plane-grid*) 2)))))
(let ((p1 (make-vector 3))
(p2 (make-vector 3)))
(dotimes (j 3)
(aset p1 j (+ (* t1 (aref normal j)) d))
(aset p2 j (+ (* t2 (aref normal j)) d)))
(glVertex3fv p1)
(glVertex3fv p2))))
(glEnd)))
(glBegin GL_POINTS)
(glVertex3fv p1)
(glVertex3fv p2)
(glVertex3fv p3)
(glEnd)))
任意の八点を通る六面体を描くソースコードを書いてください
(defun draw-hexagon (points)
(draw-polygon points 6))