// // Copyright (c) 2010 Linaro Limited // // All rights reserved. This program and the accompanying materials // are made available under the terms of the MIT License which accompanies // this distribution, and is available at // http://www.opensource.org/licenses/mit-license.php // // Contributors: // Jesse Barker - original implementation. // #include <math.h> #include "mat.h" namespace LibMatrix { namespace Mat4 { mat4 translate(float x, float y, float z) { … } mat4 scale(float x, float y, float z) { … } // // As per the OpenGL "red book" definition of rotation, from the appendix // on Homogeneous Coordinates and Transformation Matrices, the "upper left" // 3x3 portion of the result matrix is formed by: // // M = uuT + (cos a)(I - uuT) + (sin a)S // // where u is the normalized input vector, uuT is the outer product of that // vector and its transpose, I is the identity matrix and S is the matrix: // // | 0 -z' y' | // | z' 0 -x' | // | -y' x' 0 | // // where x', y' and z' are the elements of u // mat4 rotate(float angle, float x, float y, float z) { … } mat4 frustum(float left, float right, float bottom, float top, float near, float far) { … } mat4 ortho(float left, float right, float bottom, float top, float near, float far) { … } mat4 perspective(float fovy, float aspect, float zNear, float zFar) { … } mat4 lookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { … } } // namespace Mat4 } // namespace LibMatrix