1// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Matrix implementation here is col-major, both storage-wise and
6// operation-wise.
7
8#ifndef MATRIXOP_H_INCLUDED
9#define MATRIXOP_H_INCLUDED
10
11typedef float Matrix4x4[16];
12typedef float Matrix3x3[9];
13
14// result = mat1 * mat2
15extern void Matrix4x4_Multiply(Matrix4x4 result,
16                               Matrix4x4 mat1, Matrix4x4 mat2);
17
18// dst = src
19extern void Matrix4x4_Copy(Matrix4x4 dst, Matrix4x4 src);
20
21extern void Matrix4x4_LoadIdentity(Matrix4x4 mat);
22
23// mat = ScaleMatrix(sx, sy, sz) * mat
24extern void Matrix4x4_Scale(Matrix4x4 mat,
25                            float sx, float sy, float sz);
26
27// mat = TranslateMatrix(tx, ty, tz) * mat
28extern void Matrix4x4_Translate(Matrix4x4 mat,
29                                float tx, float ty, float tz);
30
31// mat = RotateMatrix(angle, ax, ay, az) * mat
32extern void Matrix4x4_Rotate(Matrix4x4 mat, float angle,
33                             float ax, float ay, float az);
34
35// mat = FrustumMatrix(left, right, bottom, top, near, far) * mat
36extern void Matrix4x4_Frustum(Matrix4x4 mat,
37                              float left, float right,
38                              float bottom, float top,
39                              float near, float far);
40
41extern void Matrix4x4_Perspective(Matrix4x4 mat, float fovy, float aspect,
42                                  float nearZ, float farZ);
43
44// [x,y,z] = mat(3x3) * [x,y,z]
45extern void Matrix4x4_Transform(Matrix4x4 mat, float *x, float *y, float *z);
46
47#endif  // MATRIXOP_H_INCLUDED
48
49