diff options
Diffstat (limited to 'lib/vec3.rb')
-rw-r--r-- | lib/vec3.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/vec3.rb b/lib/vec3.rb index 08cbf69..3069b65 100644 --- a/lib/vec3.rb +++ b/lib/vec3.rb @@ -56,10 +56,18 @@ class Vec3 self / mag end + def reflect(normal) + self - normal * dot(normal) * 2 + end + def in_unit_sphere? mag_sqr < 1 end + def near_zero?(s = 1e-8) + @x.abs < s && @y.abs < s && @z.abs < s + end + def to_s "{#{@x}, #{@y}, #{@z}}" end |