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 = ConceptChunk -> Symbol -> Space -> UnitDefn -> UnitalChunk
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 = ConceptChunk -> Symbol -> Space -> UnitDefn -> UnitalChunk
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 = ConstrConcept -> Uncertainty -> UncertQ
forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
landPos Uncertainty
defaultUncrt
launAngleUnc :: UncertQ
launAngleUnc = ConstrConcept -> Uncertainty -> UncertQ
forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
launAngle Uncertainty
defaultUncrt
launSpeedUnc :: UncertQ
launSpeedUnc = ConstrConcept -> Uncertainty -> UncertQ
forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
launSpeed Uncertainty
defaultUncrt
offsetUnc :: UncertQ
offsetUnc = ConstrConcept -> Uncertainty -> UncertQ
forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
offset Uncertainty
defaultUncrt
targPosUnc :: UncertQ
targPosUnc = ConstrConcept -> Uncertainty -> UncertQ
forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq ConstrConcept
targPos Uncertainty
defaultUncrt
flightDurUnc :: UncertQ
flightDurUnc = ConstrConcept -> Uncertainty -> UncertQ
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 = UnitalChunk -> [ConstraintE] -> ConstrConcept
forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> ConstrConcept
constrainedNRV' (ConceptChunk -> Symbol -> Space -> UnitDefn -> UnitalChunk
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 = UnitalChunk -> [ConstraintE] -> ConstrConcept
forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> ConstrConcept
constrainedNRV' (ConceptChunk -> Symbol -> Space -> UnitDefn -> UnitalChunk
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 = UnitalChunk -> [ConstraintE] -> Expr -> ConstrConcept
forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained' (ConceptChunk
-> (Stage -> Symbol) -> Space -> UnitDefn -> UnitalChunk
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
physRange (RealInterval Expr Expr -> ConstraintE)
-> RealInterval Expr Expr -> ConstraintE
forall a b. (a -> b) -> a -> b
$ (Inclusive, Expr) -> (Inclusive, Expr) -> RealInterval Expr Expr
forall a b. (Inclusive, a) -> (Inclusive, b) -> RealInterval a b
Bounded (Inclusive
Exc, Integer -> Expr
forall r. LiteralC r => Integer -> r
exactDbl Integer
0) (Inclusive
Exc, Expr -> Expr
forall r. (ExprC r, LiteralC r) => r -> r
half (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ DefinedQuantityDict -> Expr
forall c. (HasUID c, HasSymbol c) => c -> Expr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy DefinedQuantityDict
pi_)] (DefinedQuantityDict -> Expr
forall c. (HasUID c, HasSymbol c) => c -> Expr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy DefinedQuantityDict
pi_ Expr -> Expr -> Expr
forall r. ExprC r => r -> r -> r
$/ Integer -> Expr
forall r. LiteralC r => Integer -> r
exactDbl Integer
4)
launSpeed :: ConstrConcept
launSpeed = UnitalChunk -> [ConstraintE] -> Expr -> ConstrConcept
forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained' (ConceptChunk -> Symbol -> Space -> UnitDefn -> UnitalChunk
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] (Integer -> Expr
forall r. LiteralC r => Integer -> r
exactDbl Integer
100)
offset :: ConstrConcept
offset = UnitalChunk -> [ConstraintE] -> ConstrConcept
forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> ConstrConcept
constrainedNRV' (ConceptChunk -> Symbol -> Space -> UnitDefn -> UnitalChunk
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
physRange (RealInterval Expr Expr -> ConstraintE)
-> RealInterval Expr Expr -> ConstraintE
forall a b. (a -> b) -> a -> b
$ (Inclusive, Expr) -> RealInterval Expr Expr
forall b a. (Inclusive, b) -> RealInterval a b
UpFrom (Inclusive
Exc, Expr -> Expr
forall r. ExprC r => r -> r
neg (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ ConstrConcept -> Expr
forall c. (HasUID c, HasSymbol c) => c -> Expr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstrConcept
targPos)]
targPos :: ConstrConcept
targPos = UnitalChunk -> [ConstraintE] -> Expr -> ConstrConcept
forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained' (ConceptChunk -> Symbol -> Space -> UnitDefn -> UnitalChunk
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] (Integer -> Expr
forall r. LiteralC r => Integer -> r
exactDbl Integer
1000)
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 = QuantityDict -> Literal -> ConstQDef
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) (Integer -> Integer -> Literal
forall r. LiteralC r => Integer -> Integer -> r
perc Integer
2 Integer
2)