Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 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. (m matrix))
  11. (box.math.vec4:with-components ((v vec))
  12. (psetf o00 1
  13. o11 1
  14. o22 1
  15. o33 1
  16.  
  17. o03 (+ m03 vx)
  18. o13 (+ m13 vy)
  19. o23 (+ m23 vz)))
  20. o))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement