summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2022-12-20 22:48:27 +0100
committerTom Barrett <tom@tombarrett.xyz>2022-12-20 22:48:27 +0100
commite25ffd24ee2e115d8453644d3670348c3678af67 (patch)
tree31b6bffa147687592bc2f430dcbdab4f2dba3654 /src/main.zig
parent60592281229a8c6ff4f440e2b16ed4ff7bb1af20 (diff)
6.1
Diffstat (limited to 'src/main.zig')
-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 {