Advertisement
Neverlose

Untitled

Dec 14th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. function ham (vec1, vec2)
  2. local s = vec1[1]*vec2[1] - vec1[2]*vec2[2] - vec1[3]*vec2[3] - vec1[4]*vec2[4]
  3. local i = vec1[1]*vec2[2] + vec1[2]*vec2[1] + vec1[3]*vec2[4] - vec1[4]*vec2[3]
  4. local j = vec1[1]*vec2[3] - vec1[2]*vec2[4] + vec1[3]*vec2[1] + vec1[4]*vec2[2]
  5. local k = vec1[1]*vec2[4] + vec1[2]*vec2[3] - vec1[3]*vec2[2] + vec1[4]*vec2[1]
  6. local finVec = {s, i, j, k}
  7. return finVec
  8. end
  9.  
  10.  
  11. function quatVec (vec, quat)
  12. invQuat = {quat[1], -quat[2], -quat[3], -quat[4]}
  13. local finVec = ham(ham(quat, vec), invQuat)
  14. return vector.new(finVec[2], finVec[3], finVec[4])
  15. end
  16.  
  17.  
  18. return {
  19. ham = ham,
  20. quatVec = quatVec,
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement