1 #include "vector3d.h"
2
3 /* Vector functions */
4
5 bool
vector3d_eq(const Vector3D * v1,const Vector3D * v2)6 vector3d_eq(const Vector3D *v1, const Vector3D *v2)
7 {
8 return (FPeq(v1->x, v2->x) &&
9 FPeq(v1->y, v2->y) &&
10 FPeq(v1->z, v2->z));
11 }
12
13 void
vector3d_cross(Vector3D * out,const Vector3D * v1,const Vector3D * v2)14 vector3d_cross(Vector3D *out, const Vector3D *v1, const Vector3D *v2)
15 {
16 out->x = v1->y * v2->z - v1->z * v2->y;
17 out->y = v1->z * v2->x - v1->x * v2->z;
18 out->z = v1->x * v2->y - v1->y * v2->x;
19 }
20
21 float8
vector3d_scalar(Vector3D * v1,Vector3D * v2)22 vector3d_scalar(Vector3D *v1, Vector3D *v2)
23 {
24 float8 out = 0;
25
26 out += v1->x * v2->x;
27 out += v1->y * v2->y;
28 out += v1->z * v2->z;
29 return (out);
30 }
31
32 float8
vector3d_length(const Vector3D * v)33 vector3d_length(const Vector3D *v)
34 {
35 return sqrt(Sqr(v->x) + Sqr(v->y) + Sqr(v->z));
36 }
37