Move from store to flat

This commit is contained in:
2022-08-20 17:54:35 +01:00
parent 8571ab9254
commit ff9dbdf068
95 changed files with 793 additions and 748 deletions
+16 -16
View File
@@ -1,29 +1,31 @@
--{-# LANGUAGE StandaloneDeriving #-}
--{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE ScopedTypeVariables #-}
{- |
WARNING: orphan instances concerning Aeson classes and Linear.Quaternion datatypes have been introduced.
The warnings have been disabled.
-}
module Quaternion
( rotateToZ
, vToQuat
, module Linear.Quaternion
) where
module Quaternion (
rotateToZ,
vToQuat,
module Linear.Quaternion,
) where
import Data.Aeson
import Flat
import Geometry.Data
import Geometry.Vector3D
import qualified Linear.Quaternion as Q
import Linear.Quaternion
import TH.Derive
import Data.Store
import qualified Linear.Quaternion as Q
import LinearHelp
instance ToJSON a => ToJSON (Q.Quaternion a) where
toEncoding = genericToEncoding defaultOptions
instance FromJSON a => FromJSON (Q.Quaternion a)
instance FromJSON a => FromJSON (Q.Quaternion a)
-- apply a rotation as if the z axis moves to the new point.
-- i think this may instead do as if the new point moves to be on z axis
@@ -35,12 +37,10 @@ rotateToZ z1
cprod = crossProd z1 (V3 0 0 1)
vToQuat :: Point3 -> Point3 -> Q.Quaternion Float
vToQuat a b
vToQuat a b
| cprod == V3 0 0 0 = Q.axisAngle (V3 0 0 1) 0
| otherwise = Q.axisAngle cprod (angleVV3 a b)
where
cprod = crossProd a b
$($(derive [d|
instance (Store a => Deriving (Store (Quaternion a)))
|]))
deriving instance (Flat a => Flat (Quaternion a))