bgc-c/basic-geometry/hg-matrix3x3.h

105 lines
3.3 KiB
C

#ifndef _BGC_HG_MATRIX3X3_H_INCLUDED_
#define _BGC_HG_MATRIX3X3_H_INCLUDED_
#include "./vector3.h"
#include "./types.h"
#include "./hg-vector3.h"
// =================== Reset ==================== //
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix)
{
homogeneous_matrix->r1c1 = 1.0f;
homogeneous_matrix->r1c2 = 0.0f;
homogeneous_matrix->r1c2 = 0.0f;
homogeneous_matrix->r1d0 = 0.0f;
homogeneous_matrix->r2c1 = 0.0f;
homogeneous_matrix->r2c2 = 1.0f;
homogeneous_matrix->r2c2 = 0.0f;
homogeneous_matrix->r2d0 = 0.0f;
homogeneous_matrix->r3c1 = 0.0f;
homogeneous_matrix->r3c2 = 0.0f;
homogeneous_matrix->r3c2 = 1.0f;
homogeneous_matrix->r3d0 = 0.0f;
homogeneous_matrix->d0c1 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0d0 = 1.0f;
}
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix)
{
homogeneous_matrix->r1c1 = 1.0;
homogeneous_matrix->r1c2 = 0.0;
homogeneous_matrix->r1c2 = 0.0;
homogeneous_matrix->r1d0 = 0.0;
homogeneous_matrix->r2c1 = 0.0;
homogeneous_matrix->r2c2 = 1.0;
homogeneous_matrix->r2c2 = 0.0;
homogeneous_matrix->r2d0 = 0.0;
homogeneous_matrix->r3c1 = 0.0;
homogeneous_matrix->r3c2 = 0.0;
homogeneous_matrix->r3c2 = 1.0;
homogeneous_matrix->r3d0 = 0.0;
homogeneous_matrix->d0c1 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0d0 = 1.0;
}
// ==================== Make ==================== //
inline void bgc_fp32_hg_matrix3x3_make(BGC_FP32_HgMatrix3x3* homogeneous_matrix, const BGC_FP32_Matrix3x3* linear_matrix, const BGC_FP32_Vector3* shift)
{
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
homogeneous_matrix->r1d0 = shift->x1;
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
homogeneous_matrix->r2d0 = shift->x2;
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
homogeneous_matrix->r3d0 = shift->x3;
homogeneous_matrix->d0c1 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0d0 = 1.0f;
}
inline void bgc_fp64_hg_matrix3x3_make(BGC_FP64_HgMatrix3x3* homogeneous_matrix, const BGC_FP64_Matrix3x3* linear_matrix, const BGC_FP64_Vector3* shift)
{
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
homogeneous_matrix->r1d0 = shift->x1;
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
homogeneous_matrix->r2d0 = shift->x2;
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
homogeneous_matrix->r3d0 = shift->x3;
homogeneous_matrix->d0c1 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0d0 = 1.0;
}
#endif