Godzil 3 лет назад
Родитель
Сommit
6fd6f99a97
2 измененных файлов с 20 добавлено и 0 удалено
  1. 4 0
      source/include/vector.h
  2. 16 0
      source/vector.c

+ 4 - 0
source/include/vector.h

@@ -32,6 +32,10 @@ typedef struct vec4_t
 /***********************************************************************************************************************
  * Prototypes
  **********************************************************************************************************************/
+/* ---------------------------------------------- 2D Vectors operations --------------------------------------------- */
+
+
+/* ---------------------------------------------- 3D Vectors operations --------------------------------------------- */
 
 vec3_t vec3RotateX(vec3_t original, double angle);
 vec3_t vec3RotateY(vec3_t original, double angle);

+ 16 - 0
source/vector.c

@@ -10,6 +10,22 @@
 #include <vector.h>
 #include <math.h>
 
+/* ---------------------------------------------- 2D Vectors operations --------------------------------------------- */
+double vec2Getlength(vec2_t v)
+{
+    return sqrt(v.x * v.x + v.y * v.y);
+}
+
+
+
+
+/* ---------------------------------------------- 3D Vectors operations --------------------------------------------- */
+double vec3Getlength(vec3_t v)
+{
+    return sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
+}
+
+
 vec3_t vec3RotateX(vec3_t original, double angle)
 {
     vec3_t ret = {