diff options
author | Julian T <julian@jtle.dk> | 2020-05-07 09:46:56 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-05-07 09:46:56 +0200 |
commit | ba99860760eda6ec221b15190547736407723f84 (patch) | |
tree | 18aa0f770efd4d584ea44709c16c78ea82d3ec3f /vector.c | |
parent | c2bd065bafe52a3e85be7a87945ed47aec7a33d9 (diff) |
Global illumination
Diffstat (limited to 'vector.c')
-rw-r--r-- | vector.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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); |