summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index c55bc06..40ac9c7 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2,7 +2,11 @@ const std = @import("std");
const warn = @import("std").debug.print;
pub fn unit_vector(v: vec) vec {
- return v / scalar(3);
+ return v / scalar(length(v));
+}
+
+pub fn length(v: vec) f32 {
+ return @sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
}
pub fn ray_color(r: ray) vec {