Commit ef90265a authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Harish Krupo

matrix: Add weston_matrix_diag()

Add weston_matrix_diag() which gives us a diagonal matrix
populated with the elements from the passed in vector.

Commit message edit (Harish krupo)

v2: Set matrix type to WESTON_MATRIX_TRANSFORM_OTHER (Pekka)
Signed-off-by: Ville Syrjälä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Harish Krupo's avatarHarish Krupo <harish.krupo.kps@intel.com>
parent ec95ca78
......@@ -60,6 +60,8 @@ void
weston_matrix_rotate_xy(struct weston_matrix *matrix, float cos, float sin);
void
weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v);
void
weston_matrix_diag(struct weston_matrix *matrix, const struct weston_vector *v);
int
weston_matrix_invert(struct weston_matrix *inverse,
......
......@@ -129,6 +129,19 @@ weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v)
*v = t;
}
WL_EXPORT void
weston_matrix_diag(struct weston_matrix *matrix, const struct weston_vector *v)
{
unsigned c;
weston_matrix_init(matrix);
for (c = 0; c < 4; c++)
matrix->d[c * 4 + c] = v->f[c];
matrix->type = WESTON_MATRIX_TRANSFORM_OTHER;
}
static inline void
swap_rows(double *a, double *b)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment