Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun translate! (out matrix vec)
- "Translate MATRIX by VEC, storing the result in the existing matrix, OUT."
- ;; NOTE: to avoid a cons of a matrix, instead of writing this in the normal
- ;; mathematical manner of: (*! out (set-translation (id) vec) matrix) (which
- ;; applies the translation after the transfomration stored in MATRIX) we
- ;; instead do the dot product by hand (eliding a pile of terms that wipe out
- ;; to zero) to compute the new translation column. This also happens to save
- ;; a lot of operations too.
- (box.math.mat4:with-components ((o out))
- (box.math.mat4:copy! out matrix)
- (box.math.vec4:with-components ((v vec))
- (psetf
- o03 (+ o03 vx)
- o13 (+ o13 vy)
- o23 (+ o23 vz)))
- o))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement