#include <math.h>
#include <string.h>
+#ifdef __WATCOMC__
+#define inline __inline
+#endif
+
+typedef struct {
+ float x, y;
+} cgm_vec2;
+
typedef struct {
float x, y, z;
} cgm_vec3;
static inline void cgm_vlerp(cgm_vec3 *res, const cgm_vec3 *a, const cgm_vec3 *b, float t);
+#define cgm_velem(vptr, idx) ((&(vptr)->x)[idx])
+
/* --- operations on cgm_vec4 --- */
static inline void cgm_wcons(cgm_vec4 *v, float x, float y, float z, float w);
static inline void cgm_wmul_m3v4(cgm_vec4 *v, const float *m); /* (m still 16 floats) */
static inline void cgm_wmul_v4m3(cgm_vec4 *v, const float *m); /* (m still 16 floats) */
+static inline float cgm_wdot(const cgm_vec4 *a, const cgm_vec4 *b);
+
static inline float cgm_wlength(const cgm_vec4 *v);
static inline float cgm_wlength_sq(const cgm_vec4 *v);
static inline float cgm_wdist(const cgm_vec4 *a, const cgm_vec4 *b);
static inline void cgm_wlerp(cgm_vec4 *res, const cgm_vec4 *a, const cgm_vec4 *b, float t);
+#define cgm_welem(vptr, idx) ((&(vptr)->x)[idx])
+
/* --- operations on quaternions --- */
static inline void cgm_qcons(cgm_quat *q, float x, float y, float z, float w);
static inline void cgm_qconjugate(cgm_quat *q);
static inline void cgm_qinvert(cgm_quat *q);
-static inline void cgm_qrotation(cgm_quat *q, const cgm_vec3 *axis, float angle);
-static inline void cgm_qrotate(cgm_quat *q, const cgm_vec3 *axis, float angle);
+static inline void cgm_qrotation(cgm_quat *q, float angle, float x, float y, float z);
+static inline void cgm_qrotate(cgm_quat *q, float angle, float x, float y, float z);
static inline void cgm_qslerp(cgm_quat *res, const cgm_quat *a, const cgm_quat *b, float t);
static inline void cgm_qlerp(cgm_quat *res, const cgm_quat *a, const cgm_quat *b, float t);
+#define cgm_qelem(qptr, idx) ((&(qptr)->x)[idx])
+
/* --- operations on matrices --- */
static inline void cgm_mcopy(float *dest, const float *src);
static inline void cgm_mzero(float *m);
static inline float cgm_smoothstep(float a, float b, float x);
static inline float cgm_lerp(float a, float b, float t);
static inline float cgm_bezier(float a, float b, float c, float d, float t);
+static inline float cgm_bspline(float a, float b, float c, float d, float t);
+static inline float cgm_spline(float a, float b, float c, float d, float t);
static inline void cgm_discrand(cgm_vec3 *v, float rad);
static inline void cgm_sphrand(cgm_vec3 *v, float rad);