From 1a76a7adf1021187911752325b639ab72d34b6a9 Mon Sep 17 00:00:00 2001 From: Thompson Lee Date: Sun, 11 Sep 2016 17:09:53 -0400 Subject: [PATCH] Added Mtx_Diagonal(). --- include/c3d/maths.h | 10 ++++++++++ source/maths/mtx_diagonal.c | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 source/maths/mtx_diagonal.c diff --git a/include/c3d/maths.h b/include/c3d/maths.h index 215a4ce..0ef8665 100644 --- a/include/c3d/maths.h +++ b/include/c3d/maths.h @@ -495,6 +495,16 @@ void Mtx_LookAt(C3D_Mtx* out, C3D_FVec cameraPosition, C3D_FVec cameraTarget, C3 *@param[in,out] out Output matrix. */ void Mtx_Transpose(C3D_Mtx* out); + +/** + * @brief Creates a matrix with the diagonal using the given parameters. + * @param[out] out Output matrix. + * @param[in] x The X component. + * @param[in] y The Y component. + * @param[in] z The Z component. + * @param[in] w The W component. + */ +void Mtx_Diagonal(C3D_Mtx* out, float x, float y, float z, float w); ///@} ///@name Quaternion Math diff --git a/source/maths/mtx_diagonal.c b/source/maths/mtx_diagonal.c new file mode 100644 index 0000000..9b49899 --- /dev/null +++ b/source/maths/mtx_diagonal.c @@ -0,0 +1,10 @@ +#include + +void Mtx_Diagonal(C3D_Mtx* out, float x, float y, float z, float w) +{ + Mtx_Identity(out); + FVec4_Scale(out->r[0], x); + FVec4_Scale(out->r[1], y); + FVec4_Scale(out->r[2], z); + FVec4_Scale(out->r[3], w); +}