Use ValueOption instead of Option (#11)

This commit is contained in:
Patrick Stevens
2023-01-07 10:55:49 +00:00
committed by GitHub
parent 1009d7d468
commit a07ff8f852
16 changed files with 87 additions and 87 deletions

View File

@@ -21,7 +21,7 @@ module TestBoundingBox =
(Point.make ((if negate then (fun x -> -x) else id) delta) 0.0 0.0)
(Vector.make (if negate then -1.0 else 1.0) 0.0 0.0
|> Vector.unitise
|> Option.get)
|> ValueOption.get)
let property
(x : NormalFloat)
@@ -50,7 +50,7 @@ module TestBoundingBox =
(Point.make 0.0 ((if negate then (fun x -> -x) else id) delta) 0.0)
(Vector.make 0.0 (if negate then -1.0 else 1.0) 0.0
|> Vector.unitise
|> Option.get)
|> ValueOption.get)
let property
(x : NormalFloat)
@@ -74,7 +74,7 @@ module TestBoundingBox =
[<Test>]
let ``Bounding box forward, ray going backward, case 1`` () =
let ray =
Ray.make (Point.make 0.0 0.0 delta) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> Option.get)
Ray.make (Point.make 0.0 0.0 delta) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> ValueOption.get)
let z1, z2 = sort (-abs 0.0) (-abs 0.0)
let x1, x2 = sort 0.0 0.0
@@ -91,7 +91,7 @@ module TestBoundingBox =
(Point.make 0.0 0.0 ((if negate then (fun x -> -x) else id) delta))
(Vector.make 0.0 0.0 (if negate then -1.0 else 1.0)
|> Vector.unitise
|> Option.get)
|> ValueOption.get)
let property
(x : NormalFloat)
@@ -116,7 +116,7 @@ module TestBoundingBox =
[<Test>]
let ``Bounding box forward does intersect ray going forward`` () =
let ray =
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> Option.get)
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> ValueOption.get)
let box = BoundingBox.make (Point.make -1.0 -1.0 -1.0) (Point.make 1.0 1.0 1.0)

View File

@@ -10,7 +10,7 @@ module TestPlane =
[<Test>]
let ``Orthogonalise does make orthogonal vectors`` () =
let property (p : Plane) : bool =
let orth = Plane.orthonormalise p |> Option.get
let orth = Plane.orthonormalise p |> ValueOption.get
let v1, v2 = Plane.basis (Vector.make 0.0 1.0 0.0) orth
let dotVectors = UnitVector.dot (Ray.vector v1) (Ray.vector v2)
let v1Length = UnitVector.dot (Ray.vector v1) (Ray.vector v1)

View File

@@ -41,7 +41,7 @@ module TestSphere =
let rand = Random () |> FloatProducer
let ray =
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> Option.get)
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> ValueOption.get)
let strikePoint = Point.make 0.0 0.0 1.0
@@ -72,7 +72,7 @@ module TestSphere =
let rand = Random () |> FloatProducer
let ray =
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> Option.get)
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> ValueOption.get)
let strikePoint = Point.make 0.0 0.0 1.0
@@ -103,7 +103,7 @@ module TestSphere =
let rand = Random () |> FloatProducer
let ray =
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> Option.get)
Ray.make (Point.make 0.0 0.0 0.0) (Vector.make 0.0 0.0 1.0 |> Vector.unitise |> ValueOption.get)
let strikePoint = Point.make 0.0 0.0 1.0

View File

@@ -38,7 +38,7 @@ module TestSphereIntersection =
Ray.make'
(Point.make 1.462205539 -4.888279676 7.123293244)
(Vector.make -9.549697616 4.400018428 10.41024923)
|> Option.get
|> ValueOption.get
let sphere =
Sphere.make

View File

@@ -37,7 +37,7 @@ module TestUtils =
vectorGen
|> Gen.filter (fun i -> Vector.normSquared i > 0.0)
|> Gen.map Vector.unitise
|> Gen.map Option.get
|> Gen.map ValueOption.get
let rayGen : Gen<Ray> =
gen {