Work on weapon positioning

This commit is contained in:
2026-04-01 10:04:22 +01:00
parent ecdc19fb5e
commit aea7e6434e
10 changed files with 95 additions and 84 deletions
+14
View File
@@ -16,6 +16,7 @@ module Quaternion (
comp,
prePos,
module Linear.Quaternion,
qNoRoll,
) where
import Geometry.Vector
@@ -24,6 +25,8 @@ import Geometry.Data
import Geometry.Vector3D
import Linear.Quaternion
import qualified Linear.Quaternion as Q
import Control.Lens
import Linear
instance ToJSON a => ToJSON (Q.Quaternion a) where
toEncoding = genericToEncoding defaultOptions
@@ -46,6 +49,17 @@ vToQuat a b
where
cprod = crossProd a b
qNoRoll :: Point3 -> Q.Quaternion Float
--qNoRoll x = qz (argV $ x ^. _xy) * Q.axisAngle (V3 0 (-1) 0) (argV (V2 (x ^. _z) (norm (x ^. _xy))))
qNoRoll x = qNoRoll2 x * qNoRoll1 x
--qNoRoll x = Q.axisAngle (V3 0 1 0) (argV (V2 (x ^. _z) (norm (x ^. _xy)))) * qz (argV $ x ^. _xy)
--
qNoRoll1 :: Point3 -> Q.Quaternion Float
qNoRoll1 x = Q.axisAngle (V3 0 (-1) 0) . argV $ V2 (norm (x ^. _xy)) (x ^. _z)
qNoRoll2 :: Point3 -> Q.Quaternion Float
qNoRoll2 x = qz (argV $ x ^. _xy)
qToV3 :: Q.Quaternion Float -> Point3
qToV3 q = Q.rotate q (V3 1 0 0)