Subversion Repositories gelsvn

Rev

Rev 12 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef __CGLA_MAT4X4_H__
#define __CGLA_MAT4X4_H__

#include "ExceptionStandard.h"
#include "CGLA.h"
#include "Vec3f.h"
#include "Vec3Hf.h"
#include "Vec4f.h"
#include "ArithSqMat4x4Float.h"


namespace CGLA {


        /** Four by four float matrix.
                        This class is useful for transformations such as perspective projections 
                        or translation where 3x3 matrices do not suffice. */
        class Mat4x4f: public ArithSqMat4x4Float<Vec4f, Mat4x4f>
        {
        public:
  
                /// Construct a Mat4x4f from four Vec4f vectors
                Mat4x4f(Vec4f _a, Vec4f _b, Vec4f _c, Vec4f _d): 
                        ArithSqMat4x4Float<Vec4f, Mat4x4f> (_a,_b,_c,_d) {}
  
                /// Construct the 0 matrix
                Mat4x4f() {}

                /// Construct from a pointed to array of 16 floats.
                Mat4x4f(const float* sa): ArithSqMat4x4Float<Vec4f, Mat4x4f> (sa) {}
        };

        /// Create a rotation _matrix. Rotates about one of the major axes.
        Mat4x4f rotation_Mat4x4f(CGLA::Axis axis, float angle);

        /// Create a translation matrix
        Mat4x4f translation_Mat4x4f(const Vec3f&);

        /// Create a scaling matrix.
        Mat4x4f scaling_Mat4x4f(const Vec3f&);

        /// Create an identity matrix.
        inline Mat4x4f identity_Mat4x4f()
        {
                return Mat4x4f(Vec4f(1,0,0,0), 
                                                                         Vec4f(0,1,0,0), 
                                                                         Vec4f(0,0,1,0), 
                                                                         Vec4f(0,0,0,1));
        }

        /** Create a perspective matrix. Assumes the eye is at the origin and
                        that we are looking down the negative z axis.
    
                        ACTUALLY THE EYE IS NOT AT THE ORIGIN BUT BEHIND IT. CHECK UP ON
                        THIS ONE */
        Mat4x4f perspective_Mat4x4f(float d);


}
#endif