]> www.hackdaworld.org Git - physik/posic.git/blobdiff - math/math.c
nearly finished init stuff (probs with rand function!)
[physik/posic.git] / math / math.c
index 6d707e93bd7c23b355d8292273349fb37c004d30..9cfaff67296592e49da59f2346e61382ebcf3b3a 100644 (file)
@@ -7,6 +7,8 @@
 
 
 #include <string.h>
+#include <math.h>
+
 #include "math.h"
 
 int v3_add(t_3dvec *sum,t_3dvec *a,t_3dvec *b) {
@@ -64,3 +66,13 @@ int v3_cmp(t_3dvec *a,t_3dvec *b) {
        return(memcmp(a,b,sizeof(t_3dvec)));
 }
 
+double v3_absolute_square(t_3dvec *a) {
+
+       return(a->x*a->x+a->y*a->y+a->z*a->z);
+}
+
+double v3_norm(t_3dvec *a) {
+
+       return(sqrt(v3_absolute_square(a)));
+}
+