[go: up one dir, main page]

blob: 2deaf8671e4d95af411855c1e8a657d3d47d077b [file] [log] [blame]
Geoff Langf6139352014-03-03 21:44:561//
Stuart Morgan9d737962019-08-14 19:25:122// Copyright 2014 The ANGLE Project Authors. All rights reserved.
Geoff Langf6139352014-03-03 21:44:563// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
Jamie Madillad60e8e2015-09-22 16:40:316// Matrix:
7// Helper class for doing matrix math.
8//
Geoff Langf6139352014-03-03 21:44:569
Jamie Madillad60e8e2015-09-22 16:40:3110#ifndef UTIL_MATRIX_H
11#define UTIL_MATRIX_H
Geoff Langf6139352014-03-03 21:44:5612
Yuly Novikov9f0886212018-12-29 20:46:1513#include "common/vector_utils.h"
Jamie Madillba319ba2018-12-29 15:29:3314#include "util/util_export.h"
Yuly Novikov9f0886212018-12-29 20:46:1515
Jamie Madillba319ba2018-12-29 15:29:3316struct ANGLE_UTIL_EXPORT Matrix4
Geoff Langf6139352014-03-03 21:44:5617{
18 float data[16];
19
20 Matrix4();
Jamie Madillad60e8e2015-09-22 16:40:3121 Matrix4(float m00,
22 float m01,
23 float m02,
24 float m03,
25 float m10,
26 float m11,
27 float m12,
28 float m13,
29 float m20,
30 float m21,
31 float m22,
32 float m23,
33 float m30,
34 float m31,
35 float m32,
36 float m33);
Geoff Langf6139352014-03-03 21:44:5637
38 static Matrix4 identity();
Corentin Wallez922cbfc2016-11-25 21:23:1839 static Matrix4 rotate(float angle, const angle::Vector3 &p);
40 static Matrix4 translate(const angle::Vector3 &t);
41 static Matrix4 scale(const angle::Vector3 &s);
Geoff Langf6139352014-03-03 21:44:5642 static Matrix4 frustum(float l, float r, float b, float t, float n, float f);
43 static Matrix4 perspective(float fov, float aspectRatio, float n, float f);
44 static Matrix4 ortho(float l, float r, float b, float t, float n, float f);
45 static Matrix4 rollPitchYaw(float roll, float pitch, float yaw);
46
47 static Matrix4 invert(const Matrix4 &mat);
48 static Matrix4 transpose(const Matrix4 &mat);
Corentin Wallez922cbfc2016-11-25 21:23:1849 static angle::Vector3 transform(const Matrix4 &mat, const angle::Vector3 &pt);
50 static angle::Vector3 transform(const Matrix4 &mat, const angle::Vector4 &pt);
Geoff Langf6139352014-03-03 21:44:5651};
52
Jamie Madillba319ba2018-12-29 15:29:3353ANGLE_UTIL_EXPORT Matrix4 operator*(const Matrix4 &a, const Matrix4 &b);
54ANGLE_UTIL_EXPORT Matrix4 &operator*=(Matrix4 &a, const Matrix4 &b);
55ANGLE_UTIL_EXPORT Matrix4 operator*(const Matrix4 &a, float b);
56ANGLE_UTIL_EXPORT Matrix4 &operator*=(Matrix4 &a, float b);
57ANGLE_UTIL_EXPORT angle::Vector4 operator*(const Matrix4 &a, const angle::Vector4 &b);
Geoff Langf6139352014-03-03 21:44:5658
Jamie Madillba319ba2018-12-29 15:29:3359ANGLE_UTIL_EXPORT bool operator==(const Matrix4 &a, const Matrix4 &b);
60ANGLE_UTIL_EXPORT bool operator!=(const Matrix4 &a, const Matrix4 &b);
Geoff Langf6139352014-03-03 21:44:5661
Jamie Madillad60e8e2015-09-22 16:40:3162#endif // UTIL_MATRIX_H