module Dodge.Movement.Turn where import Geometry turnTo :: Float -> Point2 -> Point2 -> Float -> Float turnTo turnSpeed sp tp a | vToTarg == V2 0 0 = a | angleVV vToTarg vdir <= turnSpeed = argV vToTarg | isLHS (sp +.+ vdir) sp tp = a - turnSpeed | otherwise = a + turnSpeed where vdir = unitVectorAtAngle a vToTarg = tp -.- sp vecTurnTo :: Float -> Point2 -> Point2 -> Point2 -> Point2 vecTurnTo turnSpeed sp tp vdir | angleVV vToTarg vdir <= turnSpeed = argV vdir *.* normalizeV vToTarg | isLHS (sp +.+ vdir) sp tp = rotateV (negate turnSpeed) vdir | otherwise = rotateV turnSpeed vdir where vToTarg = tp -.- sp