Add more wall reflection/randomisation
This commit is contained in:
@@ -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.
|
||||
-}
|
||||
|
||||
Reference in New Issue
Block a user