| 1.0.2 API documentation

Functions
GLM_EXT_matrix_transform
Stable extensions

## Functions
template<typename genType >
GLM_FUNC_DECL GLM_CONSTEXPR genType | identity ()
| Builds an identity matrix.
template<typename T , qualifier Q>
GLM_FUNC_DECL mat< 4, 4, T, Q > | lookAt (vec< 3, T, Q > const &eye, vec< 3, T, Q > const &center, vec< 3, T, Q > const &up)
| Build a look at view matrix based on the default handedness. More...
template<typename T , qualifier Q>
GLM_FUNC_DECL mat< 4, 4, T, Q > | lookAtLH (vec< 3, T, Q > const &eye, vec< 3, T, Q > const &center, vec< 3, T, Q > const &up)
| Build a left handed look at view matrix. More...
template<typename T , qualifier Q>
GLM_FUNC_DECL mat< 4, 4, T, Q > | lookAtRH (vec< 3, T, Q > const &eye, vec< 3, T, Q > const &center, vec< 3, T, Q > const &up)
| Build a right handed look at view matrix. More...
template<typename T , qualifier Q>
GLM_FUNC_DECL mat< 4, 4, T, Q > | rotate (mat< 4, 4, T, Q > const &m, T angle, vec< 3, T, Q > const &axis)
| Builds a rotation 4 * 4 matrix created from an axis vector and an angle. More...
template<typename T , qualifier Q>
GLM_FUNC_DECL mat< 4, 4, T, Q > | scale (mat< 4, 4, T, Q > const &m, vec< 3, T, Q > const &v)
| Builds a scale 4 * 4 matrix created from 3 scalars. More...
template<typename T , qualifier Q>
GLM_FUNC_QUALIFIER mat< 4, 4, T, Q > | shear (mat< 4, 4, T, Q > const &m, vec< 3, T, Q > const &p, vec< 2, T, Q > const &l_x, vec< 2, T, Q > const &l_y, vec< 2, T, Q > const &l_z)
| Builds a scale 4 * 4 matrix created from point referent 3 shearers. More...
template<typename T , qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR mat< 4, 4, T, Q > | translate (mat< 4, 4, T, Q > const &m, vec< 3, T, Q > const &v)
| Builds a translation 4 * 4 matrix created from a vector of 3 components. More...

## Detailed Description

Defines functions that generate common transformation matrices.

The matrices generated by this extension use standard OpenGL fixed-function conventions. For example, the lookAt function generates a transform from world space into the specific eye space that the projective matrix functions (perspective, ortho, etc) are designed to expect. The OpenGL compatibility specifications defines the particular layout of this eye space.

Include <glm/ext/matrix_transform.hpp> to use the features of this extension.

See also
  GLM_EXT_matrix_projection
  GLM_EXT_matrix_clip_space

## Function Documentation

## ◆ lookAt()

GLM_FUNC_DECL mat<4, 4, T, Q> glm::lookAt | ( | vec< 3, T, Q > const & | eye,
|  | vec< 3, T, Q > const & | center,
|  | vec< 3, T, Q > const & | up
| ) |  |

Build a look at view matrix based on the default handedness.

Parameters

  eye | Position of the camera
  center | Position where the camera is looking at
  up | Normalized up vector, how the camera is oriented. Typically (0, 0, 1)

Template Parameters

  T | A floating-point scalar type
  Q | A value from qualifier enum

See also
  - 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)
  gluLookAt man page

## ◆ lookAtLH()

GLM_FUNC_DECL mat<4, 4, T, Q> glm::lookAtLH | ( | vec< 3, T, Q > const & | eye,
|  | vec< 3, T, Q > const & | center,
|  | vec< 3, T, Q > const & | up
| ) |  |

Build a left handed look at view matrix.

Parameters

  eye | Position of the camera
  center | Position where the camera is looking at
  up | Normalized up vector, how the camera is oriented. Typically (0, 0, 1)

Template Parameters

  T | A floating-point scalar type
  Q | A value from qualifier enum

See also
  - 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)

## ◆ lookAtRH()

GLM_FUNC_DECL mat<4, 4, T, Q> glm::lookAtRH | ( | vec< 3, T, Q > const & | eye,
|  | vec< 3, T, Q > const & | center,
|  | vec< 3, T, Q > const & | up
| ) |  |

Build a right handed look at view matrix.

Parameters

  eye | Position of the camera
  center | Position where the camera is looking at
  up | Normalized up vector, how the camera is oriented. Typically (0, 0, 1)

Template Parameters

  T | A floating-point scalar type
  Q | A value from qualifier enum

See also
  - 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)

## ◆ rotate()

GLM_FUNC_DECL mat<4, 4, T, Q> glm::rotate | ( | mat< 4, 4, T, Q > const & | m,
|  | T | angle,
|  | vec< 3, T, Q > const & | axis
| ) |  |

Builds a rotation 4 * 4 matrix created from an axis vector and an angle.

Parameters

  m | Input matrix multiplied by this rotation matrix.
  angle | Rotation angle expressed in radians.
  axis | Rotation axis, recommended to be normalized.

Template Parameters

  T | A floating-point scalar type
  Q | A value from qualifier enum

See also
  - rotate(mat<4, 4, T, Q> const& m, T angle, T x, T y, T z)
  - rotate(T angle, vec<3, T, Q> const& v)
  glRotate man page

## ◆ scale()

GLM_FUNC_DECL mat<4, 4, T, Q> glm::scale | ( | mat< 4, 4, T, Q > const & | m,
|  | vec< 3, T, Q > const & | v
| ) |  |

Builds a scale 4 * 4 matrix created from 3 scalars.

Parameters

  m | Input matrix multiplied by this scale matrix.
  v | Ratio of scaling for each axis.

Template Parameters

  T | A floating-point scalar type
  Q | A value from qualifier enum

See also
  - scale(mat<4, 4, T, Q> const& m, T x, T y, T z)
  - scale(vec<3, T, Q> const& v)
  glScale man page

## ◆ shear()

GLM_FUNC_QUALIFIER mat<4, 4, T, Q> glm::shear | ( | mat< 4, 4, T, Q > const & | m,
|  | vec< 3, T, Q > const & | p,
|  | vec< 2, T, Q > const & | l_x,
|  | vec< 2, T, Q > const & | l_y,
|  | vec< 2, T, Q > const & | l_z
| ) |  |

Builds a scale 4 * 4 matrix created from point referent 3 shearers.

Parameters

  m | Input matrix multiplied by this shear matrix.
  p | Point of shearing as reference.
  l_x | Ratio of matrix.x projection in YZ plane relative to the y-axis/z-axis.
  l_y | Ratio of matrix.y projection in XZ plane relative to the x-axis/z-axis.
  l_z | Ratio of matrix.z projection in XY plane relative to the x-axis/y-axis.

as example: [1 , l_xy, l_xz, -(l_xy+l_xz) * p_x] [x] T [x`, y`, z`, w`] = [x`, y`, z`, w`] * [l_yx, 1 , l_yz, -(l_yx+l_yz) * p_y] [y] [l_zx, l_zy, 1 , -(l_zx+l_zy) * p_z] [z] [0 , 0 , 0 , 1 ] [w]

Template Parameters

  T | A floating-point shear type
  Q | A value from qualifier enum

See also
  - shear(mat<4, 4, T, Q> const& m, T x, T y, T z)
  - shear(vec<3, T, Q> const& p)
  - shear(vec<2, T, Q> const& l_x)
  - shear(vec<2, T, Q> const& l_y)
  - shear(vec<2, T, Q> const& l_z)
  no resource...

## ◆ translate()

GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> glm::translate | ( | mat< 4, 4, T, Q > const & | m,
|  | vec< 3, T, Q > const & | v
| ) |  |

Builds a translation 4 * 4 matrix created from a vector of 3 components.

Parameters

  m | Input matrix multiplied by this translation matrix.
  v | Coordinates of a translation vector.

Template Parameters

  T | A floating-point scalar type
  Q | A value from qualifier enum

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
...
glm::mat4 m = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f));
// m[0][0] == 1.0f, m[0][1] == 0.0f, m[0][2] == 0.0f, m[0][3] == 0.0f
// m[1][0] == 0.0f, m[1][1] == 1.0f, m[1][2] == 0.0f, m[1][3] == 0.0f
// m[2][0] == 0.0f, m[2][1] == 0.0f, m[2][2] == 1.0f, m[2][3] == 0.0f
// m[3][0] == 1.0f, m[3][1] == 1.0f, m[3][2] == 1.0f, m[3][3] == 1.0f

See also
  - translate(mat<4, 4, T, Q> const& m, T x, T y, T z)
  - translate(vec<3, T, Q> const& v)
  glTranslate man page

glm::mat4
mat< 4, 4, float, defaultp > mat4
4 columns of 4 components matrix of single-precision floating-point numbers.
Definition: matrix_float4x4.hpp:20
matrix_transform.hpp
GLM_GTC_matrix_transform
glm::vec3
vec< 3, float, defaultp > vec3
3 components vector of single-precision floating-point numbers.
Definition: vector_float3.hpp:15
glm::translate
GLM_FUNC_DECL GLM_CONSTEXPR mat< 4, 4, T, Q > translate(mat< 4, 4, T, Q > const &m, vec< 3, T, Q > const &v)
Builds a translation 4 * 4 matrix created from a vector of 3 components.