From ba99860760eda6ec221b15190547736407723f84 Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 7 May 2020 09:46:56 +0200 Subject: Global illumination --- vector.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'vector.c') diff --git a/vector.c b/vector.c index 0bcd1dc..661516e 100644 --- a/vector.c +++ b/vector.c @@ -43,6 +43,17 @@ COORD_T vector_len(vector_t *v) return sqrt( v->x * v->x + v->y * v->y + v->z * v->z ); } +void vector_norm(vector_t *v) +{ + COORD_T len = vector_len(v); + if (len == 0) { + vector_set(v, 0, 0, 0); + return; + } + + vector_scale_inv(v, v, len); +} + vector_t *vector_add(vector_t *dest, vector_t *a, vector_t *b) { dest = vector_exists(dest); -- cgit v1.2.3