mirror of
https://github.com/Smaug123/ray-tracing-fsharp
synced 2025-10-11 23:08:40 +00:00
Last ValueOption (#12)
This commit is contained in:
@@ -358,8 +358,8 @@ module Sphere =
|
|||||||
|
|
||||||
let intersectionPoint =
|
let intersectionPoint =
|
||||||
match Float.compare discriminantOverFour 0.0 with
|
match Float.compare discriminantOverFour 0.0 with
|
||||||
| Comparison.Equal -> Some (-b)
|
| Comparison.Equal -> ValueSome (-b)
|
||||||
| Comparison.Less -> None
|
| Comparison.Less -> ValueNone
|
||||||
| Comparison.Greater ->
|
| Comparison.Greater ->
|
||||||
let intermediate = sqrt discriminantOverFour
|
let intermediate = sqrt discriminantOverFour
|
||||||
let i1 = intermediate - b
|
let i1 = intermediate - b
|
||||||
@@ -372,16 +372,16 @@ module Sphere =
|
|||||||
| Less -> i1
|
| Less -> i1
|
||||||
| Greater -> i2
|
| Greater -> i2
|
||||||
| Equal -> i1
|
| Equal -> i1
|
||||||
|> Some
|
|> ValueSome
|
||||||
elif i1Pos then
|
elif i1Pos then
|
||||||
Some i1
|
ValueSome i1
|
||||||
elif i2Pos then
|
elif i2Pos then
|
||||||
Some i2
|
ValueSome i2
|
||||||
else
|
else
|
||||||
None
|
ValueNone
|
||||||
|
|
||||||
match intersectionPoint with
|
match intersectionPoint with
|
||||||
| None -> ValueNone
|
| ValueNone -> ValueNone
|
||||||
| Some i ->
|
| ValueSome i ->
|
||||||
// Don't return anything that's behind us
|
// Don't return anything that's behind us
|
||||||
if Float.positive i then ValueSome i else ValueNone
|
if Float.positive i then ValueSome i else ValueNone
|
||||||
|
Reference in New Issue
Block a user