mirror of
https://github.com/Smaug123/ray-tracing-fsharp
synced 2025-10-12 23:38:40 +00:00
Perfect reflection, and Lambert, for spheres and planes (#1)
This commit is contained in:
32
RayTracing/Algebraic.fs
Normal file
32
RayTracing/Algebraic.fs
Normal 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"
|
Reference in New Issue
Block a user