Basic Transforms 続き 任意軸に対する回転 - Real-Time Rendering
Real-Time Renderingの 4章 Transforms。
任意のベクトルを軸とした回転。
;; r を軸にして origin を phi 回転する (let* ([phi (/ pi 4)] [origin (make-point 2.0 2.0 0.0 1.0)] [r (make-point 0 1 0 1)] [s (orthonormal-axis r)] [t (cross-product r s)] [m (points->matrix3 r s t)] [mt (transpose-matrix3 m)] [rotate-x (make-rotate-x-matrix3 phi)] [rotate (multiply-matrix3 mt (multiply-matrix3 rotate-x m))]) (write `(define command '(begin (draw-line ',(point->list r) ;; 元の点を描画 ',(point->list origin) ',color1) (draw-line ',(point->list r) ;; 回転後 ',(point->list (multiply-matrix3-point rotate origin)) ',color2)))))