Implement tracking rockets

This commit is contained in:
2022-03-01 18:22:47 +00:00
parent fd62b5a3b7
commit 910542a96a
11 changed files with 118 additions and 31 deletions
+11
View File
@@ -12,6 +12,17 @@ turnTo turnSpeed sp tp a
vdir = unitVectorAtAngle a
vToTarg = tp -.- sp
turnToAmount :: Float -> Point2 -> Point2 -> Float -> Float
turnToAmount turnSpeed sp tp a
| vToTarg == V2 0 0 = 0
| angleVV vToTarg vdir <= turnSpeed
= diffAngles a (argV vToTarg) -- TODO check correctness
| isLHS (sp +.+ vdir) sp tp = negate turnSpeed
| otherwise = turnSpeed
where
vdir = unitVectorAtAngle a
vToTarg = tp -.- sp
vecTurnTo :: Float -> Point2 -> Point2 -> Point2 -> Point2
vecTurnTo turnSpeed sp tp vdir
| angleVV vToTarg vdir <= turnSpeed