# lv_matrix.h (/api/misc/lv_matrix_h)



<ApiSummary functions="12" structs="1" />

Functions [#functions]

<ApiMember kind="function" name="lv_matrix_identity" file="misc/lv_matrix.h" line="48" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L48">
  lv_matrix_identity [#lv_matrix_identity]

  Set matrix to identity matrix

  ```c title=" " lineNumbers=1
  void lv_matrix_identity(lv_matrix_t *matrix)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                   | Description         |
  | -------- | ------------------------------------------------------ | ------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" /> | pointer to a matrix |
</ApiMember>

<ApiMember kind="function" name="lv_matrix_translate" file="misc/lv_matrix.h" line="56" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L56">
  lv_matrix_translate [#lv_matrix_translate]

  Translate the matrix to new position

  ```c title=" " lineNumbers=1
  void lv_matrix_translate(lv_matrix_t *matrix, float tx, float ty)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                   | Description                            |
  | -------- | ------------------------------------------------------ | -------------------------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" /> | pointer to a matrix                    |
  | `tx`     | `float`                                                | the amount of translate in y direction |
  | `ty`     | `float`                                                |                                        |
</ApiMember>

<ApiMember kind="function" name="lv_matrix_scale" file="misc/lv_matrix.h" line="64" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L64">
  lv_matrix_scale [#lv_matrix_scale]

  Change the scale factor of the matrix

  ```c title=" " lineNumbers=1
  void lv_matrix_scale(lv_matrix_t *matrix, float scale_x, float scale_y)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name      | Type                                                   | Description                          |
  | --------- | ------------------------------------------------------ | ------------------------------------ |
  | `matrix`  | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" /> | pointer to a matrix                  |
  | `scale_x` | `float`                                                | the scale factor for the X direction |
  | `scale_y` | `float`                                                | the scale factor for the Y direction |
</ApiMember>

<ApiMember kind="function" name="lv_matrix_rotate" file="misc/lv_matrix.h" line="71" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L71">
  lv_matrix_rotate [#lv_matrix_rotate]

  Rotate the matrix with origin

  ```c title=" " lineNumbers=1
  void lv_matrix_rotate(lv_matrix_t *matrix, float degree)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                   | Description         |
  | -------- | ------------------------------------------------------ | ------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" /> | pointer to a matrix |
  | `degree` | `float`                                                | angle to rotate     |
</ApiMember>

<ApiMember kind="function" name="lv_matrix_skew" file="misc/lv_matrix.h" line="79" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L79">
  lv_matrix_skew [#lv_matrix_skew]

  Change the skew factor of the matrix

  ```c title=" " lineNumbers=1
  void lv_matrix_skew(lv_matrix_t *matrix, float skew_x, float skew_y)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                   | Description                     |
  | -------- | ------------------------------------------------------ | ------------------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" /> | pointer to a matrix             |
  | `skew_x` | `float`                                                | the skew factor for x direction |
  | `skew_y` | `float`                                                | the skew factor for y direction |
</ApiMember>

<ApiMember kind="function" name="lv_matrix_multiply" file="misc/lv_matrix.h" line="86" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L86">
  lv_matrix_multiply [#lv_matrix_multiply]

  Multiply two matrix and store the result to the first one

  ```c title=" " lineNumbers=1
  void lv_matrix_multiply(lv_matrix_t *matrix, const lv_matrix_t *mul)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                         | Description         |
  | -------- | ------------------------------------------------------------ | ------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" />       | pointer to a matrix |
  | `mul`    | <ApiLink name="lv_matrix_t" display="const lv_matrix_t *" /> |                     |
</ApiMember>

<ApiMember kind="function" name="lv_matrix_inverse" file="misc/lv_matrix.h" line="94" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L94">
  lv_matrix_inverse [#lv_matrix_inverse]

  Invert the matrix

  ```c title=" " lineNumbers=1
  bool lv_matrix_inverse(lv_matrix_t *matrix, const lv_matrix_t *m)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                         | Description                          |
  | -------- | ------------------------------------------------------------ | ------------------------------------ |
  | `matrix` | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" />       | pointer to a matrix                  |
  | `m`      | <ApiLink name="lv_matrix_t" display="const lv_matrix_t *" /> | pointer to another matrix (optional) |

  **Returns:** <ApiLink name="bool" /> — true: the matrix is invertible, false: the matrix is singular and cannot be inverted
</ApiMember>

<ApiMember kind="function" name="lv_matrix_transform_precise_point" file="misc/lv_matrix.h" line="102" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L102">
  lv_matrix_transform_precise_point [#lv_matrix_transform_precise_point]

  Transform a point by a matrix

  ```c title=" " lineNumbers=1
  lv_point_precise_t lv_matrix_transform_precise_point(const lv_matrix_t *matrix, const lv_point_precise_t *point)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                                       | Description         |
  | -------- | -------------------------------------------------------------------------- | ------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="const lv_matrix_t *" />               | pointer to a matrix |
  | `point`  | <ApiLink name="lv_point_precise_t" display="const lv_point_precise_t *" /> | pointer to a point  |

  **Returns:** <ApiLink name="lv_point_precise_t" /> — the transformed point
</ApiMember>

<ApiMember kind="function" name="lv_matrix_transform_area" file="misc/lv_matrix.h" line="110" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L110">
  lv_matrix_transform_area [#lv_matrix_transform_area]

  Transform an area by a matrix

  ```c title=" " lineNumbers=1
  lv_area_t lv_matrix_transform_area(const lv_matrix_t *matrix, const lv_area_t *area)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                         | Description         |
  | -------- | ------------------------------------------------------------ | ------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="const lv_matrix_t *" /> | pointer to a matrix |
  | `area`   | <ApiLink name="lv_area_t" display="const lv_area_t *" />     | pointer to an area  |

  **Returns:** <ApiLink name="lv_area_t" /> — the transformed area
</ApiMember>

<ApiMember kind="function" name="lv_matrix_is_identity" file="misc/lv_matrix.h" line="117" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L117">
  lv_matrix_is_identity [#lv_matrix_is_identity]

  Check if the matrix is identity

  ```c title=" " lineNumbers=1
  bool lv_matrix_is_identity(const lv_matrix_t *matrix)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                         | Description         |
  | -------- | ------------------------------------------------------------ | ------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="const lv_matrix_t *" /> | pointer to a matrix |

  **Returns:** <ApiLink name="bool" /> — true: the matrix is identity , false: the matrix is not identity
</ApiMember>

<ApiMember kind="function" name="lv_matrix_is_identity_or_translation" file="misc/lv_matrix.h" line="124" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L124">
  lv_matrix_is_identity_or_translation [#lv_matrix_is_identity_or_translation]

  Check if the matrix is identity or translation matrix

  ```c title=" " lineNumbers=1
  bool lv_matrix_is_identity_or_translation(const lv_matrix_t *matrix)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                         | Description         |
  | -------- | ------------------------------------------------------------ | ------------------- |
  | `matrix` | <ApiLink name="lv_matrix_t" display="const lv_matrix_t *" /> | pointer to a matrix |

  **Returns:** <ApiLink name="bool" /> — true: the matrix is identity or translation matrix, false: the matrix is not identity or translation matrix
</ApiMember>

<ApiMember kind="function" name="lv_matrix_transpose" file="misc/lv_matrix.h" line="132" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_matrix.h#L132">
  lv_matrix_transpose [#lv_matrix_transpose]

  Transpose a matrix.

  ```c title=" " lineNumbers=1
  void lv_matrix_transpose(const lv_matrix_t *src, lv_matrix_t *dst)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                                                         | Description                                                                                                                                  |
  | ----- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
  | `src` | <ApiLink name="lv_matrix_t" display="const lv_matrix_t *" /> | pointer to the source matrix. If NULL, the function returns.                                                                                 |
  | `dst` | <ApiLink name="lv_matrix_t" display="lv_matrix_t *" />       | pointer to the destination matrix. If NULL, the function returns. Note: src and dst may point to the same matrix for in-place transposition. |
</ApiMember>

Structs [#structs]

<ApiMember kind="struct" name="_lv_matrix_t">
  \_lv_matrix_t [#_lv_matrix_t]

  | Member | Type          | Description |
  | ------ | ------------- | ----------- |
  | `m`    | `float[3][3]` |             |
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_types.h&#x22;, &#x22;lv_area.h&#x22;]" includedBy="[&#x22;lv_draw.h&#x22;, &#x22;lv_draw_vector.h&#x22;, &#x22;lv_nanovg_utils.h&#x22;, &#x22;lv_vg_lite_utils.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_math.h&#x22;]" />
