[igt-dev] [PATCH i-g-t 5/8] lib: Add igt_matrix
Chris Wilson
chris at chris-wilson.co.uk
Tue Feb 27 21:33:13 UTC 2018
Quoting Ville Syrjala (2018-02-27 21:21:17)
> +#include "igt_core.h"
> +#include "igt_matrix.h"
> +
> +/**
> + * SECTION:igt_matrix
> + * @short_description: Matrix math library
> + * @title: Matrix
> + * @include: igt.h
> + *
> + * This library contains helper functions for basic matrix math.
> + * The library operates on #igt_mat4 and #igt_vec4 structures.
> + */
> +
> +/**
> + * igt_matrix_print:
> + * @m: the matrix
> + *
> + * Print out the matrix elements.
> + */
> +void igt_matrix_print(const struct igt_mat4 *m)
> +{
> + for (int row = 0; row < 4; row++) {
> + igt_info("|");
> + for (int col = 0; col < 4; col++) {
> + igt_info("%4.4f,", m->d[col * 4 + row]);
#define m(row, col) ((col) * 4 + (row)) ?
> + }
> + igt_info("|\n");
> + }
> +}
> +
> +/**
> + * igt_matrix_identity:
> + *
> + * Returns:
> + * An identity matrix.
> + */
> +struct igt_mat4 igt_matrix_identity(void)
> +{
> + struct igt_mat4 ret = {
> + .d[0 * 4 + 0] = 1.0f,
> + .d[1 * 4 + 1] = 1.0f,
> + .d[2 * 4 + 2] = 1.0f,
> + .d[3 * 4 + 3] = 1.0f,
> + };
static ?
Didn't spot any typos.
-Chris
More information about the igt-dev
mailing list