module Drasil.Projectile.Unitals where

import Language.Drasil
import Language.Drasil.Display (Symbol(..))
import Language.Drasil.ShortHands (lD, lTheta, lV, lP, lT, lS, vEpsilon)

import Data.Drasil.Quantities.Math (pi_)

import Data.Drasil.Constraints (gtZeroConstr)
import Data.Drasil.SI_Units (radian, metre, second)
import Data.Drasil.Units.Physics (velU)

import qualified Drasil.Projectile.Concepts as C (flightDur, offset,
  flightDur, landPos, launAngle, launSpeed, offset, targPos, projSpeed, projPos)

projSpeed :: UnitalChunk
projSpeed :: UnitalChunk
projSpeed = forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc ConceptChunk
C.projSpeed ([Symbol] -> Symbol
Concat [Symbol
lV, String -> Symbol
label String
"(", Symbol
lT, String -> Symbol
label String
")"]) Space
Real UnitDefn
velU

projPos :: UnitalChunk
projPos :: UnitalChunk
projPos = forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc ConceptChunk
C.projPos ([Symbol] -> Symbol
Concat [Symbol
lP, String -> Symbol
label String
"(", Symbol
lT, String -> Symbol
label String
")"]) Space
Real UnitDefn
metre

---
landPosUnc, launAngleUnc, launSpeedUnc, offsetUnc, targPosUnc,
  flightDurUnc :: UncertQ
landPosUnc :: UncertQ
landPosUnc   = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
landPos   Uncertainty
defaultUncrt
launAngleUnc :: UncertQ
launAngleUnc = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
launAngle Uncertainty
defaultUncrt
launSpeedUnc :: UncertQ
launSpeedUnc = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
launSpeed Uncertainty
defaultUncrt
offsetUnc :: UncertQ
offsetUnc    = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
offset    Uncertainty
defaultUncrt
targPosUnc :: UncertQ
targPosUnc   = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
targPos   Uncertainty
defaultUncrt
flightDurUnc :: UncertQ
flightDurUnc = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
flightDur Uncertainty
defaultUncrt

flightDur, landPos, launAngle, launSpeed, offset, targPos :: ConstrConcept
flightDur :: ConstrConcept
flightDur = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> ConstrConcept
constrainedNRV' (forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc       ConceptChunk
C.flightDur (Symbol -> String -> Symbol
subStr Symbol
lT String
"flight") Space
Real UnitDefn
second) [ConstraintE
gtZeroConstr]
landPos :: ConstrConcept
landPos   = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> ConstrConcept
constrainedNRV' (forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc       ConceptChunk
C.landPos   (Symbol -> String -> Symbol
subStr Symbol
lP String
"land"  ) Space
Real UnitDefn
metre ) [ConstraintE
gtZeroConstr]
launAngle :: ConstrConcept
launAngle = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained'    (forall c u.
(Concept c, IsUnit u) =>
c -> (Stage -> Symbol) -> Space -> u -> UnitalChunk
ucStaged ConceptChunk
C.launAngle (Symbol -> Stage -> Symbol
autoStage Symbol
lTheta  ) Space
Real UnitDefn
radian) [RealInterval Expr Expr -> ConstraintE
physc forall a b. (a -> b) -> a -> b
$ forall a b. (Inclusive, a) -> (Inclusive, b) -> RealInterval a b
Bounded (Inclusive
Exc, forall r. LiteralC r => Integer -> r
exactDbl Integer
0) (Inclusive
Exc, forall r. (ExprC r, LiteralC r) => r -> r
half forall a b. (a -> b) -> a -> b
$ forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy DefinedQuantityDict
pi_)] (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy DefinedQuantityDict
pi_ forall r. ExprC r => r -> r -> r
$/ forall r. LiteralC r => Integer -> r
exactDbl Integer
4)
launSpeed :: ConstrConcept
launSpeed = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained'    (forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc       ConceptChunk
C.launSpeed (Symbol -> String -> Symbol
subStr Symbol
lV String
"launch") Space
Real UnitDefn
velU  ) [ConstraintE
gtZeroConstr] (forall r. LiteralC r => Integer -> r
exactDbl Integer
100)
offset :: ConstrConcept
offset    = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> ConstrConcept
constrainedNRV' (forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc       ConceptChunk
C.offset    (Symbol -> String -> Symbol
subStr Symbol
lD String
"offset") Space
Real UnitDefn
metre ) [RealInterval Expr Expr -> ConstraintE
physc forall a b. (a -> b) -> a -> b
$ forall b a. (Inclusive, b) -> RealInterval a b
UpFrom (Inclusive
Exc, forall r. ExprC r => r -> r
neg forall a b. (a -> b) -> a -> b
$ forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstrConcept
targPos)]
targPos :: ConstrConcept
targPos   = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained'    (forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc       ConceptChunk
C.targPos   (Symbol -> String -> Symbol
subStr Symbol
lP String
"target") Space
Real UnitDefn
metre ) [ConstraintE
gtZeroConstr] (forall r. LiteralC r => Integer -> r
exactDbl Integer
1000)

---
-- The output contains a message, as a string, so it needs to be a quantity
message :: QuantityDict
message :: QuantityDict
message = String -> NP -> Symbol -> Space -> QuantityDict
vc String
"message" (Sentence -> NP
nounPhraseSent (String -> Sentence
S String
"output message as a string")) Symbol
lS Space
String

---
tol :: ConstQDef
tol :: ConstQDef
tol = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef (String -> NP -> (Stage -> Symbol) -> Space -> QuantityDict
vcSt String
"tol" (String -> NP
nounPhraseSP String
"hit tolerance") (Symbol -> Stage -> Symbol
autoStage Symbol
vEpsilon) Space
Real) (forall r. LiteralC r => Integer -> Integer -> r
perc Integer
2 Integer
2)