Go to the documentation of this file.
21 #define DR_MATHCALL static __forceinline
23 #define DR_MATHCALL static inline
26 #define DR_PI 3.14159265358979323846
27 #define DR_PIF 3.14159265358979323846f
71 return radians * 57.29577951308232087685f;
77 return degrees * 0.01745329251994329577f;
100 return vec4f(v[0], v[1], v[2], v[3]);
104 return vec4f(0, 0, 0, 0);
108 return vec4f(1, 1, 1, 1);
130 return vec4f(a.
x * x, a.
y * x, a.
z * x, a.
w * x);
140 m0.
x*v.
x + m0.
y*v.
y + m0.
z*v.
z + m0.
w*v.
w,
141 m1.
x*v.
x + m1.
y*v.
y + m1.
z*v.
z + m1.
w*v.
w,
142 m2.
x*v.
x + m2.
y*v.
y + m2.
z*v.
z + m2.
w*v.
w,
143 m3.
x*v.
x + m3.
y*v.
y + m3.
z*v.
z + m3.
w*v.
w
175 return vec3f(v[0], v[1], v[2]);
179 return vec3f(0, 0, 0);
183 return vec3f(1, 1, 1);
204 return vec3f(a.
x * x, a.
y * x, a.
z * x);
216 return a.
x*b.
x + a.
y*b.
y + a.
z*b.
z;
277 return vec2f(v[0], v[1]);
306 return vec2f(a.
x * x, a.
y * x);
318 return a.
x*b.
x + a.
y*b.
y;
346 return atanf(a.
y / a.
x) - atanf(b.
y / b.
x);
351 float c = cosf(angleInRadians);
352 float s = sinf(angleInRadians);
370 result.
col[0] = col0;
371 result.
col[1] = col1;
372 result.
col[2] = col2;
373 result.
col[3] = col3;
391 float rml = right - left;
392 float tmb = top - bottom;
393 float fmn = zfar - znear;
395 float rpl = right + left;
396 float tpb = top + bottom;
397 float fpn = zfar + znear;
400 result.
col[0] =
vec4f(2/rml, 0, 0, 0);
401 result.
col[1] =
vec4f(0, 2/tmb, 0, 0);
402 result.
col[2] =
vec4f(0, 0, -2/fmn, 0);
403 result.
col[3] =
vec4f(-(rpl/rml), -(tpb/tmb), -(fpn/fmn), 1);
410 float f = (float)tan(
DR_PI/2 - fovy/2);
413 result.
col[0] =
vec4f(
f / aspect, 0, 0, 0);
415 result.
col[2] =
vec4f(0, 0, (zfar + znear) / (znear - zfar), -1);
416 result.
col[3] =
vec4f(0, 0, (2 * zfar * znear) / (znear - zfar), 0);
438 result.
col[3] =
vec4f(translation.
x, translation.
y, translation.
z, 1);
445 float c = cosf(angleInRadians);
446 float s = sinf(angleInRadians);
464 result.
col[0] =
vec4f(xx * (1 - c) + c, xy * (1 - c) - zs, xz * (1 - c) + ys, 0);
465 result.
col[1] =
vec4f(xy * (1 - c) + zs, yy * (1 - c) + c, yz * (1 - c) - xs, 0);
466 result.
col[2] =
vec4f(xz * (1 - c) - ys, yz * (1 - c) + xs, zz * (1 - c) + c, 0);
498 a0.
x*b0.
x + a1.
x*b0.
y + a2.
x*b0.
z + a3.
x*b0.
w,
499 a0.
y*b0.
x + a1.
y*b0.
y + a2.
y*b0.
z + a3.
y*b0.
w,
500 a0.
z*b0.
x + a1.
z*b0.
y + a2.
z*b0.
z + a3.
z*b0.
w,
501 a0.
w*b0.
x + a1.
w*b0.
y + a2.
w*b0.
z + a3.
w*b0.
w
505 a0.
x*b1.
x + a1.
x*b1.
y + a2.
x*b1.
z + a3.
x*b1.
w,
506 a0.
y*b1.
x + a1.
y*b1.
y + a2.
y*b1.
z + a3.
y*b1.
w,
507 a0.
z*b1.
x + a1.
z*b1.
y + a2.
z*b1.
z + a3.
z*b1.
w,
508 a0.
w*b1.
x + a1.
w*b1.
y + a2.
w*b1.
z + a3.
w*b1.
w
512 a0.
x*b2.
x + a1.
x*b2.
y + a2.
x*b2.
z + a3.
x*b2.
w,
513 a0.
y*b2.
x + a1.
y*b2.
y + a2.
y*b2.
z + a3.
y*b2.
w,
514 a0.
z*b2.
x + a1.
z*b2.
y + a2.
z*b2.
z + a3.
z*b2.
w,
515 a0.
w*b2.
x + a1.
w*b2.
y + a2.
w*b2.
z + a3.
w*b2.
w
519 a0.
x*b3.
x + a1.
x*b3.
y + a2.
x*b3.
z + a3.
x*b3.
w,
520 a0.
y*b3.
x + a1.
y*b3.
y + a2.
y*b3.
z + a3.
y*b3.
w,
521 a0.
z*b3.
x + a1.
z*b3.
y + a2.
z*b3.
z + a3.
z*b3.
w,
522 a0.
w*b3.
x + a1.
w*b3.
y + a2.
w*b3.
z + a3.
w*b3.
w
536 m0.
x*v.
x + m1.
x*v.
y + m2.
x*v.
z + m3.
x*v.
w,
537 m0.
y*v.
x + m1.
y*v.
y + m2.
y*v.
z + m3.
y*v.
w,
538 m0.
z*v.
x + m1.
z*v.
y + m2.
z*v.
z + m3.
z*v.
w,
539 m0.
w*v.
x + m1.
w*v.
y + m2.
w*v.
z + m3.
w*v.
w
562 return quatf(v[0], v[1], v[2], v[3]);
567 return quatf(0, 0, 0, 1);
592 result.
scale = scale;
626 #if (defined(_MSC_VER) && defined(_M_X64)) || defined(__SSE2__)
630 #if !defined(DISABLE_SSE) && defined(SUPPORTS_SSE)
635 #if defined(__MINGW32__)
638 #include <emmintrin.h>
DR_MATHCALL float vec2_length(vec2 a)
DR_MATHCALL vec3 vec3_cross(vec3 a, vec3 b)
DR_MATHCALL vec2 vec2_div(vec2 a, vec2 b)
DR_MATHCALL vec3 vec3_triangle_normal(vec3 p1, vec3 p2, vec3 p3)
DR_MATHCALL quat quatv(const float *v)
DR_MATHCALL vec3 vec3_div(vec3 a, vec3 b)
DR_MATHCALL quat quat_identity()
DR_MATHCALL vec2 vec2_mul(vec2 a, vec2 b)
DR_MATHCALL float vec3_length2(vec3 a)
DR_MATHCALL mat4 mat4f(vec4 col0, vec4 col1, vec4 col2, vec4 col3)
DR_MATHCALL vec3 vec3_sub(vec3 a, vec3 b)
DR_MATHCALL vec3 vec3f(float x, float y, float z)
DR_MATHCALL vec3 vec3_one()
DR_MATHCALL vec4 vec4_zero()
DR_MATHCALL mat4 mat4_perspective(float fovy, float aspect, float znear, float zfar)
DR_MATHCALL vec2 vec2_sub(vec2 a, vec2 b)
DR_MATHCALL mat4 mat4_rotate(float angleInRadians, vec3 axis)
DR_MATHCALL mat4 mat4_ortho(float left, float right, float bottom, float top, float znear, float zfar)
DR_MATHCALL mat4 mat4_scale(vec3 scale)
DR_MATHCALL float vec3_dot(vec3 a, vec3 b)
DR_MATHCALL float vec3_length(vec3 a)
DR_MATHCALL vec4 vec4_one()
DR_MATHCALL mat4 mat4_vulkan_clip_correction()
DR_MATHCALL vec3 vec3_mul_1f(vec3 a, float x)
DR_MATHCALL vec2 vec2v(const float *v)
DR_MATHCALL vec3 vec3_add(vec3 a, vec3 b)
DR_MATHCALL mat4 mat4_identity()
DR_MATHCALL float dr_radians(float degrees)
DR_MATHCALL mat4 mat4_mul(mat4 a, mat4 b)
DR_MATHCALL float vec2_length2(vec2 a)
DR_MATHCALL transform_t transform_init(vec3 position, quat rotation, vec3 scale)
DR_MATHCALL vec3 vec3v(const float *v)
DR_MATHCALL vec2 vec2_normalize(vec2 a)
DR_MATHCALL mat4 mat4_translate(vec3 translation)
DR_MATHCALL vec4 vec4_mul_1f(vec4 a, float x)
DR_MATHCALL transform_t transform_identity()
DR_MATHCALL vec4 vec4_mul(vec4 a, vec4 b)
DR_MATHCALL vec2 vec2_mul_1f(vec2 a, float x)
DR_MATHCALL float vec2_angle(vec2 a, vec2 b)
DR_MATHCALL vec2 vec2f(float x, float y)
DR_MATHCALL vec3 vec3_mul(vec3 a, vec3 b)
DR_MATHCALL float vec2_dot(vec2 a, vec2 b)
DR_MATHCALL quat quatf(float x, float y, float z, float w)
DR_MATHCALL transform_t transform_translate(transform_t transform, vec3 offset)
DR_MATHCALL vec4 mat4_mul_vec4(mat4 m, vec4 v)
DR_MATHCALL vec2 vec2_one()
DR_MATHCALL vec3 vec3_zero()
DR_MATHCALL vec2 vec2_rotate(vec2 a, float angleInRadians)
DR_MATHCALL vec4 vec4_sub(vec4 a, vec4 b)
DR_MATHCALL vec2 vec2_add(vec2 a, vec2 b)
DR_MATHCALL vec2 vec2_zero()
DR_MATHCALL vec3 vec3_normalize(vec3 a)
DR_MATHCALL vec4 vec4_mul_mat4(vec4 v, mat4 m)
DR_MATHCALL vec4 vec4f(float x, float y, float z, float w)
DR_MATHCALL vec4 vec4v(const float *v)
DR_MATHCALL float dr_degrees(float radians)
DR_MATHCALL vec4 vec4_div(vec4 a, vec4 b)
DR_MATHCALL vec4 vec4_add(vec4 a, vec4 b)