Move from store to flat
This commit is contained in:
+16
-16
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user