Added Mtx_Diagonal().

This commit is contained in:
Thompson Lee 2016-09-11 17:09:53 -04:00
parent b32275ee94
commit 1a76a7adf1
2 changed files with 20 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,10 @@
#include <c3d/maths.h>
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);
}