27 lines
480 B
C
27 lines
480 B
C
|
|
#ifndef MATHPRIMITIVES_H
|
||
|
|
#define MATHPRIMITIVES_H
|
||
|
|
|
||
|
|
#include <math.h>
|
||
|
|
#include <xmmintrin.h>
|
||
|
|
|
||
|
|
struct Vec3 {
|
||
|
|
double x;
|
||
|
|
double y;
|
||
|
|
double z;
|
||
|
|
};
|
||
|
|
|
||
|
|
static inline struct Vec3 vec3_add(struct Vec3 a, struct Vec3 b) {
|
||
|
|
struct Vec3 c;
|
||
|
|
c.x = a.x + b.x;
|
||
|
|
c.y = a.y + b.y;
|
||
|
|
c.z = a.z + b.z;
|
||
|
|
return c;
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline bool vec3_eql_tol(struct Vec3 a, struct Vec3 b, double tol) {
|
||
|
|
return fabs(a.x - b.x) < tol && fabs(a.y - b.y) < tol &&
|
||
|
|
fabs(a.z - b.z) < tol;
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif
|