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

import Language.Drasil
import Language.Drasil.Chunk.Concept.NamedCombinators (combineNINI)
import Drasil.Database (mkUid)
import Language.Drasil.Display (Symbol(Atop), Decoration(Magnitude))
import Language.Drasil.ShortHands

import qualified Data.Drasil.Concepts.Math as CM (area, diameter, norm, orient,
    surArea, surface)
import Data.Drasil.Concepts.Math (euclidSpace, normal, perp, unit_, vector)
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    = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"gradient")      (String -> NP
forall a. String -> NPG a
cn' String
"gradient")
  (String -> Sentence
S String
"degree of steepness of a graph at any point")
  (Symbol -> Stage -> Symbol
forall a b. a -> b -> a
const Symbol
lNabla) Space
Real
normalVect :: DefinedQuantityDict
normalVect  = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"normal vector") (ConceptChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
combineNINI ConceptChunk
normal ConceptChunk
vector)
  (String -> Sentence
S String
"unit outward normal vector for a surface")
  (Symbol -> Stage -> Symbol
forall a b. a -> b -> a
const (Symbol -> Stage -> Symbol) -> Symbol -> Stage -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
vec Symbol
lN) Space
Real
uNormalVect :: DefinedQuantityDict
uNormalVect = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"normal vector") (ConceptChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
combineNINI ConceptChunk
normal ConceptChunk
vector)
  (String -> Sentence
S String
"unit outward normal vector for a surface")
  (Symbol -> Stage -> Symbol
forall a b. a -> b -> a
const (Symbol -> Stage -> Symbol) -> Symbol -> Stage -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
vec (Symbol -> Symbol) -> Symbol -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
hat Symbol
lN) Space
Real
unitVect :: DefinedQuantityDict
unitVect    = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"unit_vect")     (ConceptChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
combineNINI ConceptChunk
unit_ ConceptChunk
vector)
  (String -> Sentence
S String
"a vector that has a magnitude of one")
  (Symbol -> Stage -> Symbol
forall a b. a -> b -> a
const (Symbol -> Stage -> Symbol) -> Symbol -> Stage -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
vec (Symbol -> Symbol) -> Symbol -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
hat Symbol
lI) Space
Real
unitVectj :: DefinedQuantityDict
unitVectj   = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"unit_vect")     (ConceptChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
combineNINI ConceptChunk
unit_ ConceptChunk
vector)
  (String -> Sentence
S String
"a vector that has a magnitude of one")
  (Symbol -> Stage -> Symbol
forall a b. a -> b -> a
const (Symbol -> Stage -> Symbol) -> Symbol -> Stage -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
vec (Symbol -> Symbol) -> Symbol -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
hat Symbol
lJ) Space
Real
perpVect :: DefinedQuantityDict
perpVect    = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"perp_vect")     (ConceptChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
combineNINI ConceptChunk
perp ConceptChunk
vector)
  (String -> Sentence
S String
"vector perpendicular or 90 degrees to another vector")
  (Symbol -> Stage -> Symbol
forall a b. a -> b -> a
const (Symbol -> Stage -> Symbol) -> Symbol -> Stage -> Symbol
forall a b. (a -> b) -> a -> b
$ Symbol -> Symbol
vec Symbol
lN) Space
Real
pi_ :: DefinedQuantityDict
pi_    = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"pi")     (String -> NP
forall a. String -> NPG a
cn' String
"ratio of circumference to diameter for any circle")
           (String -> Sentence
S String
"The ratio of a circle's circumference to its diameter")
           (Symbol -> Symbol -> Stage -> Symbol
staged Symbol
lPi (String -> Symbol
variable String
"pi")) Space
Real
posInf :: DefinedQuantityDict
posInf = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"PosInf") (String -> NP
forall a. String -> NPG a
cn' String
"Positive Infinity")
           (String -> Sentence
S String
"the limit of a sequence or function that eventually exceeds any prescribed bound")
           (Symbol -> Symbol -> Stage -> Symbol
staged Symbol
lPosInf (String -> Symbol
variable String
"posInf")) Space
Real
negInf :: DefinedQuantityDict
negInf = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"NegInf") (String -> NP
forall a. String -> NPG a
cn' String
"Negative Infinity")
           (String -> Sentence
S String
"Opposite of positive infinity")
           (Symbol -> Symbol -> Stage -> Symbol
staged Symbol
lNegInf (String -> Symbol
variable String
"posInf")) Space
Real
euclidNorm :: DefinedQuantityDict
euclidNorm  = UID
-> NP
-> Sentence
-> (Stage -> Symbol)
-> Space
-> DefinedQuantityDict
quantNoUnit' (String -> UID
mkUid String
"euclidNorm")    (ConceptChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
combineNINI ConceptChunk
euclidSpace ConceptChunk
CM.norm)
  (String -> Sentence
S String
"euclidean norm")
  (Symbol -> Stage -> Symbol
forall a b. a -> b -> a
const (Symbol -> Stage -> Symbol) -> Symbol -> Stage -> Symbol
forall a b. (a -> b) -> a -> b
$ 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)