Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. (defun translate! (out matrix vec)
  2. "Translate MATRIX by VEC, storing the result in the existing matrix, OUT."
  3. ;; NOTE: to avoid a cons of a matrix, instead of writing this in the normal
  4. ;; mathematical manner of: (*! out (set-translation (id) vec) matrix) (which
  5. ;; applies the translation after the transfomration stored in MATRIX) we
  6. ;; instead do the dot product by hand (eliding a pile of terms that wipe out
  7. ;; to zero) to compute the new translation column. This also happens to save
  8. ;; a lot of operations too.
  9. (box.math.mat4:with-components ((o out))
  10. (box.math.mat4:copy! out matrix)
  11. (box.math.vec4:with-components ((v vec))
  12. (psetf
  13. o03 (+ o03 vx)
  14. o13 (+ o13 vy)
  15. o23 (+ o23 vz)))
  16. o))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement