Skip to content

Commit

Permalink
bug fix: check properly for integer in onRay
Browse files Browse the repository at this point in the history
This was a pretty silly bug.  Hint: to check whether a Rational is an
integer you have to look at its *denominator*, not its numerator.
  • Loading branch information
byorgey committed Mar 17, 2020
1 parent 7c9b8e7 commit 305710b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Active/Ray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ onRay x (Ray c d k p) =
-- - otherwise c - d <= x <= c
-- also need x == c + p + kt for some integer t.
-- hence compute (x - c - p) / k and check whether it is integer.
upperBound && lowerBound && (numerator ((x - c - p) / k) == 1)
upperBound && lowerBound && (denominator ((x - c - p) / k) == 1)
where
upperBound = case d of
Duration d'
Expand Down

0 comments on commit 305710b

Please sign in to comment.