-- | Assigns a symbol and possibly units (quantities) to mathematical quantities.
module Data.Drasil.Quantities.Math where

import Language.Drasil
import Language.Drasil.Display (Symbol(Atop), Decoration(Magnitude))
import Language.Drasil.ShortHands

import qualified Data.Drasil.Concepts.Math as CM (area, diameter, euclidN, gradient,
    normalV, orient, perpV, pi_, posInf, negInf, surArea, surface, unitV)
import Data.Drasil.SI_Units (metre, m_2, radian)

-- * May Not Have Units

mathquants :: [DefinedQuantityDict]
mathquants :: [DefinedQuantityDict]
mathquants = [DefinedQuantityDict
gradient, DefinedQuantityDict
normalVect, DefinedQuantityDict
unitVect, DefinedQuantityDict
perpVect,
  DefinedQuantityDict
pi_, DefinedQuantityDict
posInf, DefinedQuantityDict
negInf, DefinedQuantityDict
euclidNorm]

mathunitals :: [DefinedQuantityDict]
mathunitals :: [DefinedQuantityDict]
mathunitals = [DefinedQuantityDict
area, DefinedQuantityDict
diameter, DefinedQuantityDict
surface, DefinedQuantityDict
surArea, DefinedQuantityDict
orientation]

gradient, normalVect, unitVect, unitVectj, euclidNorm, perpVect,
  pi_, posInf, negInf, uNormalVect :: DefinedQuantityDict

gradient :: DefinedQuantityDict
gradient    = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit ConceptChunk
CM.gradient Symbol
lNabla         Space
Real
normalVect :: DefinedQuantityDict
normalVect  = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit ConceptChunk
CM.normalV  (Symbol -> Symbol
vec Symbol
lN)       Space
Real
uNormalVect :: DefinedQuantityDict
uNormalVect = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit ConceptChunk
CM.normalV  (Symbol -> Symbol
vec (Symbol -> Symbol) -> Symbol -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
hat Symbol
lN) Space
Real
unitVect :: DefinedQuantityDict
unitVect    = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit ConceptChunk
CM.unitV    (Symbol -> Symbol
vec (Symbol -> Symbol) -> Symbol -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
hat Symbol
lI) Space
Real
unitVectj :: DefinedQuantityDict
unitVectj   = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit ConceptChunk
CM.unitV    (Symbol -> Symbol
vec (Symbol -> Symbol) -> Symbol -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
hat Symbol
lJ) Space
Real
perpVect :: DefinedQuantityDict
perpVect    = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit ConceptChunk
CM.perpV    (Symbol -> Symbol
vec Symbol
lN)       Space
Real
pi_ :: DefinedQuantityDict
pi_         = ConceptChunk
-> (Stage -> Symbol)
-> Space
-> Maybe UnitDefn
-> DefinedQuantityDict
dqd'      ConceptChunk
CM.pi_      (Symbol -> Symbol -> Stage -> Symbol
staged Symbol
lPi (String -> Symbol
variable String
"pi")) Space
Real Maybe UnitDefn
forall a. Maybe a
Nothing
posInf :: DefinedQuantityDict
posInf      = ConceptChunk
-> (Stage -> Symbol)
-> Space
-> Maybe UnitDefn
-> DefinedQuantityDict
dqd'      ConceptChunk
CM.posInf   (Symbol -> Symbol -> Stage -> Symbol
staged Symbol
lPosInf (String -> Symbol
variable String
"posInf")) Space
Real Maybe UnitDefn
forall a. Maybe a
Nothing
negInf :: DefinedQuantityDict
negInf      = ConceptChunk
-> (Stage -> Symbol)
-> Space
-> Maybe UnitDefn
-> DefinedQuantityDict
dqd'      ConceptChunk
CM.negInf   (Symbol -> Symbol -> Stage -> Symbol
staged Symbol
lNegInf (String -> Symbol
variable String
"posInf")) Space
Real Maybe UnitDefn
forall a. Maybe a
Nothing
euclidNorm :: DefinedQuantityDict
euclidNorm  = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit ConceptChunk
CM.euclidN  (Decoration -> Symbol -> Symbol
Atop Decoration
Magnitude (Symbol -> Symbol) -> Symbol -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
vec Symbol
lD) Space
Real

-- * With Units

area, diameter, surface, surArea, orientation :: DefinedQuantityDict

area :: DefinedQuantityDict
area        = ConceptChunk -> Symbol -> Space -> UnitDefn -> DefinedQuantityDict
dqd ConceptChunk
CM.area     Symbol
cA   Space
Real UnitDefn
m_2
diameter :: DefinedQuantityDict
diameter    = ConceptChunk -> Symbol -> Space -> UnitDefn -> DefinedQuantityDict
dqd ConceptChunk
CM.diameter Symbol
lD   Space
Real UnitDefn
metre
surface :: DefinedQuantityDict
surface     = ConceptChunk -> Symbol -> Space -> UnitDefn -> DefinedQuantityDict
dqd ConceptChunk
CM.surface  Symbol
cS   Space
Real UnitDefn
m_2
surArea :: DefinedQuantityDict
surArea     = ConceptChunk -> Symbol -> Space -> UnitDefn -> DefinedQuantityDict
dqd ConceptChunk
CM.surArea  Symbol
cA   Space
Real UnitDefn
m_2
orientation :: DefinedQuantityDict
orientation = ConceptChunk -> Symbol -> Space -> UnitDefn -> DefinedQuantityDict
dqd ConceptChunk
CM.orient   Symbol
lPhi Space
Real UnitDefn
radian

-- * Constants

piConst :: ConstQDef
piConst :: ConstQDef
piConst = DefinedQuantityDict -> Literal -> ConstQDef
forall c e.
(Quantity c, MayHaveUnit c, Concept c) =>
c -> e -> QDefinition e
mkQuantDef DefinedQuantityDict
pi_ (Double -> Literal
forall r. LiteralC r => Double -> r
dbl Double
3.14159265)