Perfect reflection, and Lambert, for spheres and planes (#1)

This commit is contained in:
Patrick Stevens
2021-04-06 23:47:30 +01:00
committed by GitHub
parent 301976863f
commit eefaa92d0e
30 changed files with 1625 additions and 114 deletions

32
RayTracing/Algebraic.fs Normal file
View File

@@ -0,0 +1,32 @@
namespace RayTracing
type Algebraic =
| Sqrt of Algebraic
| Rational of Rational
| Sum of Algebraic * Algebraic
| Times of Algebraic * Algebraic
| Subtract of Algebraic * Algebraic
| Negate of Algebraic
| Reciprocal of Algebraic
module Algebraic =
let ofInt (i : int) = Rational (Rational.ofInt i)
let ofRational (r : Rational) = Rational r
let add (a1 : Algebraic) (a2 : Algebraic) : Algebraic =
Sum (a1, a2)
let times (a1 : Algebraic) (a2 : Algebraic) : Algebraic =
Times (a1, a2)
let sqrt (a1 : Algebraic) : Algebraic =
Sqrt a1
let negate (a1 : Algebraic) : Algebraic =
Negate a1
let reciprocal (a1 : Algebraic) : Algebraic =
Reciprocal a1
let equal (a1 : Algebraic) (a2 : Algebraic) : bool =
failwith "TODO"