master
ブランチ master
ShaderPlayground / deps / glm / glm / ext / matrix_transform.hpp
5.9 KB、144行 生 Blame 履歴
1/// @ref ext_matrix_transform
2/// @file glm/ext/matrix_transform.hpp
3///
4/// @defgroup ext_matrix_transform GLM_EXT_matrix_transform
5/// @ingroup ext
6///
7/// Defines functions that generate common transformation matrices.
8///
9/// The matrices generated by this extension use standard OpenGL fixed-function
10/// conventions. For example, the lookAt function generates a transform from world
11/// space into the specific eye space that the projective matrix functions
12/// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility
13/// specifications defines the particular layout of this eye space.
14///
15/// Include <glm/ext/matrix_transform.hpp> to use the features of this extension.
16///
17/// @see ext_matrix_projection
18/// @see ext_matrix_clip_space
19
20#pragma once
21
22// Dependencies
23#include "../gtc/constants.hpp"
24#include "../geometric.hpp"
25#include "../trigonometric.hpp"
26#include "../matrix.hpp"
27
28#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
29# pragma message("GLM: GLM_EXT_matrix_transform extension included")
30#endif
31
32namespace glm
33{
34 /// @addtogroup ext_matrix_transform
35 /// @{
36
37 /// Builds an identity matrix.
38 template<typename genType>
39 GLM_FUNC_DECL GLM_CONSTEXPR genType identity();
40
41 /// Builds a translation 4 * 4 matrix created from a vector of 3 components.
42 ///
43 /// @param m Input matrix multiplied by this translation matrix.
44 /// @param v Coordinates of a translation vector.
45 ///
46 /// @tparam T A floating-point scalar type
47 /// @tparam Q A value from qualifier enum
48 ///
49 /// @code
50 /// #include <glm/glm.hpp>
51 /// #include <glm/gtc/matrix_transform.hpp>
52 /// ...
53 /// glm::mat4 m = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f));
54 /// // m[0][0] == 1.0f, m[0][1] == 0.0f, m[0][2] == 0.0f, m[0][3] == 0.0f
55 /// // m[1][0] == 0.0f, m[1][1] == 1.0f, m[1][2] == 0.0f, m[1][3] == 0.0f
56 /// // m[2][0] == 0.0f, m[2][1] == 0.0f, m[2][2] == 1.0f, m[2][3] == 0.0f
57 /// // m[3][0] == 1.0f, m[3][1] == 1.0f, m[3][2] == 1.0f, m[3][3] == 1.0f
58 /// @endcode
59 ///
60 /// @see - translate(mat<4, 4, T, Q> const& m, T x, T y, T z)
61 /// @see - translate(vec<3, T, Q> const& v)
62 /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml">glTranslate man page</a>
63 template<typename T, qualifier Q>
64 GLM_FUNC_DECL mat<4, 4, T, Q> translate(
65 mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v);
66
67 /// Builds a rotation 4 * 4 matrix created from an axis vector and an angle.
68 ///
69 /// @param m Input matrix multiplied by this rotation matrix.
70 /// @param angle Rotation angle expressed in radians.
71 /// @param axis Rotation axis, recommended to be normalized.
72 ///
73 /// @tparam T A floating-point scalar type
74 /// @tparam Q A value from qualifier enum
75 ///
76 /// @see - rotate(mat<4, 4, T, Q> const& m, T angle, T x, T y, T z)
77 /// @see - rotate(T angle, vec<3, T, Q> const& v)
78 /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glRotate.xml">glRotate man page</a>
79 template<typename T, qualifier Q>
80 GLM_FUNC_DECL mat<4, 4, T, Q> rotate(
81 mat<4, 4, T, Q> const& m, T angle, vec<3, T, Q> const& axis);
82
83 /// Builds a scale 4 * 4 matrix created from 3 scalars.
84 ///
85 /// @param m Input matrix multiplied by this scale matrix.
86 /// @param v Ratio of scaling for each axis.
87 ///
88 /// @tparam T A floating-point scalar type
89 /// @tparam Q A value from qualifier enum
90 ///
91 /// @see - scale(mat<4, 4, T, Q> const& m, T x, T y, T z)
92 /// @see - scale(vec<3, T, Q> const& v)
93 /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glScale.xml">glScale man page</a>
94 template<typename T, qualifier Q>
95 GLM_FUNC_DECL mat<4, 4, T, Q> scale(
96 mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v);
97
98 /// Build a right handed look at view matrix.
99 ///
100 /// @param eye Position of the camera
101 /// @param center Position where the camera is looking at
102 /// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1)
103 ///
104 /// @tparam T A floating-point scalar type
105 /// @tparam Q A value from qualifier enum
106 ///
107 /// @see - frustum(T const& left, T const& right, T const& bottom, T const& top, T const& nearVal, T const& farVal) frustum(T const& left, T const& right, T const& bottom, T const& top, T const& nearVal, T const& farVal)
108 template<typename T, qualifier Q>
109 GLM_FUNC_DECL mat<4, 4, T, Q> lookAtRH(
110 vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up);
111
112 /// Build a left handed look at view matrix.
113 ///
114 /// @param eye Position of the camera
115 /// @param center Position where the camera is looking at
116 /// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1)
117 ///
118 /// @tparam T A floating-point scalar type
119 /// @tparam Q A value from qualifier enum
120 ///
121 /// @see - frustum(T const& left, T const& right, T const& bottom, T const& top, T const& nearVal, T const& farVal) frustum(T const& left, T const& right, T const& bottom, T const& top, T const& nearVal, T const& farVal)
122 template<typename T, qualifier Q>
123 GLM_FUNC_DECL mat<4, 4, T, Q> lookAtLH(
124 vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up);
125
126 /// Build a look at view matrix based on the default handedness.
127 ///
128 /// @param eye Position of the camera
129 /// @param center Position where the camera is looking at
130 /// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1)
131 ///
132 /// @tparam T A floating-point scalar type
133 /// @tparam Q A value from qualifier enum
134 ///
135 /// @see - frustum(T const& left, T const& right, T const& bottom, T const& top, T const& nearVal, T const& farVal) frustum(T const& left, T const& right, T const& bottom, T const& top, T const& nearVal, T const& farVal)
136 /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml">gluLookAt man page</a>
137 template<typename T, qualifier Q>
138 GLM_FUNC_DECL mat<4, 4, T, Q> lookAt(
139 vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up);
140
141 /// @}
142}//namespace glm
143
144#include "matrix_transform.inl"