#pragma once #include "math.h" #include "matrices.h" inline static struct mat4x4 translation(float x, float y, float z) { return mat4x4(1.0f, 0.0f, 0.0f, x, 0.0f, 1.0f, 0.0f, y, 0.0f, 0.0f, 1.0f, z, 0.0f, 0.0f, 0.0f, 1.0f); } inline static struct mat4x4 scaling(float x, float y, float z) { return mat4x4(x, 0.0f, 0.0f, 0.0f, 0.0f, y, 0.0f, 0.0f, 0.0f, 0.0f, z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); } static const float tau = 6.283185307179586; inline static struct mat4x4 rotation_x(float r) { return mat4x4(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, cosf(r), -sinf(r), 0.0f, 0.0f, sinf(r), cosf(r), 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); } inline static struct mat4x4 rotation_y(float r) { return mat4x4( cosf(r), 0.0f, sinf(r), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -sinf(r), 0.0f, cosf(r), 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); } inline static struct mat4x4 rotation_z(float r) { return mat4x4( cosf(r), -sinf(r), 0.0f, 0.0f, sinf(r), cosf(r), 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); } inline static struct mat4x4 shearing(float xy, float xz, float yx, float yz, float zx, float zy) { return mat4x4(1.0f, xy, xz, 0.0f, yx, 1.0f, yz, 0.0f, zx, zy, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); }