MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_matrix4x4.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_MATRIX4X4_H_1614657758
12#define INCGUARD_MGL_MATRIX4X4_H_1614657758
13
15#include <mgl/mgl_environment.h>
16
17namespace MGL
18{
20constexpr float kIdentityMatrix4x4Array[16] =
21{
22 1.0f, 0.0f, 0.0f, 0.0f,
23 0.0f, 1.0f, 0.0f, 0.0f,
24 0.0f, 0.0f, 1.0f, 0.0f,
25 0.0f, 0.0f, 0.0f, 1.0f
26};
27
30{
32
33 /* ------------------------------------------------------------------------- */
37 /* ------------------------------------------------------------------------- */
38 constexpr Matrix4x4() noexcept
39 : column()
40 {
41 }
42
43 /* ------------------------------------------------------------------------- */
48 /* ------------------------------------------------------------------------- */
49 constexpr Matrix4x4(const Vector4 vectorArray[4]) noexcept
50 {
51 column[0] = vectorArray[0];
52 column[1] = vectorArray[1];
53 column[2] = vectorArray[2];
54 column[3] = vectorArray[3];
55 }
56
57 /* ------------------------------------------------------------------------- */
62 /* ------------------------------------------------------------------------- */
63 constexpr Matrix4x4(const float array[16]) noexcept
64 {
65 column[0] = Vector4(array[0], array[1], array[2], array[3]);
66 column[1] = Vector4(array[4], array[5], array[6], array[7]);
67 column[2] = Vector4(array[8], array[9], array[10], array[11]);
68 column[3] = Vector4(array[12], array[13], array[14], array[15]);
69 }
70
71 /* ------------------------------------------------------------------------- */
75 /* ------------------------------------------------------------------------- */
76 constexpr void Identity() noexcept
77 {
79 }
80
81 /* ------------------------------------------------------------------------- */
85 /* ------------------------------------------------------------------------- */
86 float *GetArray() noexcept
87 {
88 return reinterpret_cast<float *>(column);
89 }
90};
91
92// サイズチェック
93static_assert(sizeof(Matrix4x4) == 16 * sizeof(float), "[MGL] Matrix4x4 is not float[16]");
94
96constexpr Matrix4x4 kIdentityMatrix4x4 = Matrix4x4(kIdentityMatrix4x4Array);
97
98} // namespace MGL
99
100#endif // INCGUARD_MGL_MATRIX4X4_H_1614657758
101
102// vim: et ts=4 sw=4 sts=4
MGL 環境定義
constexpr float kIdentityMatrix4x4Array[16]
単位行列を生成するための配列
Definition mgl_matrix4x4.h:20
constexpr Matrix4x4 kIdentityMatrix4x4
単位行列の定数
Definition mgl_matrix4x4.h:96
MGL 4Dベクトル
4x4行列
Definition mgl_matrix4x4.h:30
float * GetArray() noexcept
値の配列を取得
Definition mgl_matrix4x4.h:86
constexpr Matrix4x4() noexcept
ゼロ初期化
Definition mgl_matrix4x4.h:38
Vector4 column[4]
行列を表す4つのカラム
Definition mgl_matrix4x4.h:31
constexpr Matrix4x4(const float array[16]) noexcept
floatの配列で初期化
Definition mgl_matrix4x4.h:63
constexpr void Identity() noexcept
単位行列化
Definition mgl_matrix4x4.h:76
constexpr Matrix4x4(const Vector4 vectorArray[4]) noexcept
Vector4の配列で初期化
Definition mgl_matrix4x4.h:49
4Dベクトル
Definition mgl_vector4.h:18