1//
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.
5//
6
7#ifndef SAMPLE_UTIL_MATRIX_H
8#define SAMPLE_UTIL_MATRIX_H
9
10#include "Vector.h"
11
12struct Matrix4
13{
14    float data[16];
15
16    Matrix4();
17    Matrix4(float m00, float m01, float m02, float m03,
18            float m10, float m11, float m12, float m13,
19            float m20, float m21, float m22, float m23,
20            float m30, float m31, float m32, float m33);
21
22    static Matrix4 identity();
23    static Matrix4 rotate(float angle, const Vector3 &p);
24    static Matrix4 translate(const Vector3 &t);
25    static Matrix4 scale(const Vector3 &s);
26    static Matrix4 frustum(float l, float r, float b, float t, float n, float f);
27    static Matrix4 perspective(float fov, float aspectRatio, float n, float f);
28    static Matrix4 ortho(float l, float r, float b, float t, float n, float f);
29    static Matrix4 rollPitchYaw(float roll, float pitch, float yaw);
30
31    static Matrix4 invert(const Matrix4 &mat);
32    static Matrix4 transpose(const Matrix4 &mat);
33    static Vector3 transform(const Matrix4 &mat, const Vector3 &pt);
34    static Vector3 transform(const Matrix4 &mat, const Vector4 &pt);
35};
36
37Matrix4 operator*(const Matrix4 &a, const Matrix4 &b);
38Matrix4 &operator*=(Matrix4 &a, const Matrix4 &b);
39Matrix4 operator*(const Matrix4 &a, float b);
40Matrix4 &operator*=(Matrix4 &a, float b);
41Vector4 operator*(const Matrix4 &a, const Vector4 &b);
42
43bool operator==(const Matrix4 &a, const Matrix4 &b);
44bool operator!=(const Matrix4 &a, const Matrix4 &b);
45
46#endif // SAMPLE_UTIL_MATRIX_H
47