2 // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 // Helper class for doing matrix math.
15 #include "common/vector_utils.h"
17 struct ANGLE_EXPORT Matrix4
39 static Matrix4 identity();
40 static Matrix4 rotate(float angle, const angle::Vector3 &p);
41 static Matrix4 translate(const angle::Vector3 &t);
42 static Matrix4 scale(const angle::Vector3 &s);
43 static Matrix4 frustum(float l, float r, float b, float t, float n, float f);
44 static Matrix4 perspective(float fov, float aspectRatio, float n, float f);
45 static Matrix4 ortho(float l, float r, float b, float t, float n, float f);
46 static Matrix4 rollPitchYaw(float roll, float pitch, float yaw);
48 static Matrix4 invert(const Matrix4 &mat);
49 static Matrix4 transpose(const Matrix4 &mat);
50 static angle::Vector3 transform(const Matrix4 &mat, const angle::Vector3 &pt);
51 static angle::Vector3 transform(const Matrix4 &mat, const angle::Vector4 &pt);
54 ANGLE_EXPORT Matrix4 operator*(const Matrix4 &a, const Matrix4 &b);
55 ANGLE_EXPORT Matrix4 &operator*=(Matrix4 &a, const Matrix4 &b);
56 ANGLE_EXPORT Matrix4 operator*(const Matrix4 &a, float b);
57 ANGLE_EXPORT Matrix4 &operator*=(Matrix4 &a, float b);
58 ANGLE_EXPORT angle::Vector4 operator*(const Matrix4 &a, const angle::Vector4 &b);
60 ANGLE_EXPORT bool operator==(const Matrix4 &a, const Matrix4 &b);
61 ANGLE_EXPORT bool operator!=(const Matrix4 &a, const Matrix4 &b);
63 #endif // UTIL_MATRIX_H