-- | Create a @Following@ from a line, normalizing it (by rotation)
--   so that it starts in the positive x direction.
follow :: RealFloat n => Trail' Line V2 n -> Following n
follow t = Following $ (t # rotate (signedAngleBetween unitX s)) `tag` theta
  where
    s     = tangentAtStart t
    e     = tangentAtEnd t
    theta = signedAngleBetween e s

-- | Project out the line from a `Following`.
--
--   If trails are considered equivalent up to rotation, then
--   'unfollow' and 'follow' are inverse.
follow :: RealFloat n => Trail' Line V2 n -> Following n
follow t = Following $ (t # rotate (signedAngleBetween unitX s)) `tag` theta
  where
    s     = tangentAtStart t
    e     = tangentAtEnd t
    theta = signedAngleBetween e s

-- | Project out the line from a `Following`.
--
--   If trails are considered equivalent up to rotation, then
--   'unfollow' and 'follow' are inverse.
follow t = Following $ (t # rotate (signedAngleBetween unitX s)) `tag` theta
  where
    s     = tangentAtStart t
    e     = tangentAtEnd t
    theta = signedAngleBetween e s

-- | Project out the line from a `Following`.
--
--   If trails are considered equivalent up to rotation, then
--   'unfollow' and 'follow' are inverse.