Add more wall reflection/randomisation

This commit is contained in:
2024-12-22 10:42:10 +00:00
parent 84821a1531
commit acba8de359
4 changed files with 122 additions and 79 deletions
+14
View File
@@ -139,6 +139,20 @@ difference x y
reflectIn :: Point2 -> Point2 -> Point2
reflectIn line vec = rotateV (2 * angleBetween line vec) vec
-- takes an angle of entry (measured from x axis) and two wall points and gives a
-- reflected angle (from x axis)
reflectAngle :: Float -> Point2 -> Point2 -> Float
reflectAngle a x y = 2 * argV (x - y) - a
{- | Find the representation (by applying +-pi) of an angle
- that is nearest to another given angle -}
nearestAngleRep :: Float -> Float -> Float
nearestAngleRep a b
| b >= a && b - a <= pi = b
| b >= a = nearestAngleRep a (b - 2*pi)
| a - b <= pi = b
| otherwise = nearestAngleRep a (b + 2*pi)
{- | Find angle between two points.
Not normalised, ranges from -2*pi to 2*pi.
-}