-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvector3d.c
38 lines (30 loc) · 802 Bytes
/
vector3d.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "vector3d.h"
/*!
\file
\brief Vector functions
*/
bool vector3d_eq ( const Vector3D * v1, const Vector3D * v2 )
{
return (
FPeq(v1->x, v2->x) &&
FPeq(v1->y, v2->y) &&
FPeq(v1->z, v2->z)
);
}
Vector3D * vector3d_cross ( Vector3D * out , const Vector3D * v1 , const Vector3D * v2 )
{
out->x = v1->y * v2->z - v1->z * v2->y;
out->y = v1->z * v2->x - v1->x * v2->z;
out->z = v1->x * v2->y - v1->y * v2->x;
return out;
}
float8 vector3d_scalar ( Vector3D * v1 , Vector3D * v2 ){
float8 out = 0;
out += v1->x * v2->x;
out += v1->y * v2->y;
out += v1->z * v2->z;
return ( out );
}
float8 vector3d_length ( const Vector3D * v ){
return sqrt( sqr(v->x) + sqr(v->y) + sqr(v->z) );
}