updated cgmath
[dosdemo] / libs / cgmath / cgmath.h
index 8e6871d..5dc7e13 100644 (file)
 #endif
 
 typedef struct {
 #endif
 
 typedef struct {
+       float x, y;
+} cgm_vec2;
+
+typedef struct {
        float x, y, z;
 } cgm_vec3;
 
        float x, y, z;
 } cgm_vec3;
 
@@ -91,6 +95,8 @@ static inline void cgm_vrotate_euler(cgm_vec3 *v, float a, float b, float c, enu
 
 static inline void cgm_vlerp(cgm_vec3 *res, const cgm_vec3 *a, const cgm_vec3 *b, float t);
 
 
 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);
 
 /* --- operations on cgm_vec4 --- */
 static inline void cgm_wcons(cgm_vec4 *v, float x, float y, float z, float w);
 
@@ -106,6 +112,8 @@ static inline void cgm_wmul_v4m43(cgm_vec4 *v, const float *m);     /* doesn't affec
 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 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 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);
@@ -114,6 +122,8 @@ static inline void cgm_wnormalize(cgm_vec4 *v);
 
 static inline void cgm_wlerp(cgm_vec4 *res, const cgm_vec4 *a, const cgm_vec4 *b, float t);
 
 
 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);
 
 /* --- operations on quaternions --- */
 static inline void cgm_qcons(cgm_quat *q, float x, float y, float z, float w);
 
@@ -128,12 +138,14 @@ static inline void cgm_qnormalize(cgm_quat *q);
 static inline void cgm_qconjugate(cgm_quat *q);
 static inline void cgm_qinvert(cgm_quat *q);
 
 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);
 
 
 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);
 /* --- operations on matrices --- */
 static inline void cgm_mcopy(float *dest, const float *src);
 static inline void cgm_mzero(float *m);
@@ -214,6 +226,8 @@ static inline float cgm_rad_to_deg(float rad);
 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_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);
 
 static inline void cgm_discrand(cgm_vec3 *v, float rad);
 static inline void cgm_sphrand(cgm_vec3 *v, float rad);