Subversion Repositories gelsvn

Rev

Rev 2 | Rev 12 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 10
1
#ifndef __CGLA_MAT4X4_H__
1
#ifndef __CGLA_MAT4X4_H__
2
#define __CGLA_MAT4X4_H__
2
#define __CGLA_MAT4X4_H__
3
 
3
 
4
#include "ExceptionStandard.h"
4
#include "ExceptionStandard.h"
5
#include "CGLA.h"
5
#include "CGLA.h"
6
#include "Vec3f.h"
6
#include "Vec3f.h"
7
#include "Vec3Hf.h"
7
#include "Vec3Hf.h"
8
#include "Vec4f.h"
8
#include "Vec4f.h"
9
#include "ArithSqMat4x4Float.h"
9
#include "ArithSqMat4x4Float.h"
10
 
10
 
11
 
11
 
12
namespace CGLA {
12
namespace CGLA {
13
 
13
 
14
 
14
 
15
	/** Four by four float matrix.
15
	/** Four by four float matrix.
16
			This class is useful for transformations such as perspective projections 
16
			This class is useful for transformations such as perspective projections 
17
			or translation where 3x3 matrices do not suffice. */
17
			or translation where 3x3 matrices do not suffice. */
18
	class Mat4x4f: public ArithSqMat4x4Float<Vec4f, Mat4x4f>
18
	class Mat4x4f: public ArithSqMat4x4Float<Vec4f, Mat4x4f>
19
	{
19
	{
20
	public:
20
	public:
21
  
21
  
22
		/// Construct a Mat4x4f from four Vec4f vectors
22
		/// Construct a Mat4x4f from four Vec4f vectors
23
		Mat4x4f(Vec4f _a, Vec4f _b, Vec4f _c, Vec4f _d): 
23
		Mat4x4f(Vec4f _a, Vec4f _b, Vec4f _c, Vec4f _d): 
24
			ArithSqMat4x4Float<Vec4f, Mat4x4f> (_a,_b,_c,_d) {}
24
			ArithSqMat4x4Float<Vec4f, Mat4x4f> (_a,_b,_c,_d) {}
25
  
25
  
26
		/// Construct the 0 matrix
26
		/// Construct the NaN matrix
27
		Mat4x4f() {}
27
		Mat4x4f() {}
28
 
28
 
-
 
29
		/// Construct a matrix with identical elements.
-
 
30
		Mat4x4f(float a): 
-
 
31
			ArithSqMat4x4Float<Vec4f, Mat4x4f> (a) {}
-
 
32
 
29
		/// Construct from a pointed to array of 16 floats.
33
		/// Construct from a pointed to array of 16 floats.
-
 
34
		explicit Mat4x4f(const float* sa): 
30
		Mat4x4f(const float* sa): ArithSqMat4x4Float<Vec4f, Mat4x4f> (sa) {}
35
			ArithSqMat4x4Float<Vec4f, Mat4x4f> (sa) {}
-
 
36
 
31
	};
37
	};
32
 
38
 
33
	/// Create a rotation _matrix. Rotates about one of the major axes.
39
	/// Create a rotation _matrix. Rotates about one of the major axes.
34
	Mat4x4f rotation_Mat4x4f(CGLA::Axis axis, float angle);
40
	Mat4x4f rotation_Mat4x4f(CGLA::Axis axis, float angle);
35
 
41
 
36
	/// Create a translation matrix
42
	/// Create a translation matrix
37
	Mat4x4f translation_Mat4x4f(const Vec3f&);
43
	Mat4x4f translation_Mat4x4f(const Vec3f&);
38
 
44
 
39
	/// Create a scaling matrix.
45
	/// Create a scaling matrix.
40
	Mat4x4f scaling_Mat4x4f(const Vec3f&);
46
	Mat4x4f scaling_Mat4x4f(const Vec3f&);
41
 
47
 
42
	/// Create an identity matrix.
48
	/// Create an identity matrix.
43
	inline Mat4x4f identity_Mat4x4f()
49
	inline Mat4x4f identity_Mat4x4f()
44
	{
50
	{
45
		return Mat4x4f(Vec4f(1,0,0,0), 
51
		return Mat4x4f(Vec4f(1,0,0,0), 
46
									 Vec4f(0,1,0,0), 
52
									 Vec4f(0,1,0,0), 
47
									 Vec4f(0,0,1,0), 
53
									 Vec4f(0,0,1,0), 
48
									 Vec4f(0,0,0,1));
54
									 Vec4f(0,0,0,1));
49
	}
55
	}
50
 
56
 
51
	/** Create a perspective matrix. Assumes the eye is at the origin and
57
	/** Create a perspective matrix. Assumes the eye is at the origin and
52
			that we are looking down the negative z axis.
58
			that we are looking down the negative z axis.
53
    
59
    
54
			ACTUALLY THE EYE IS NOT AT THE ORIGIN BUT BEHIND IT. CHECK UP ON
60
			ACTUALLY THE EYE IS NOT AT THE ORIGIN BUT BEHIND IT. CHECK UP ON
55
			THIS ONE */
61
			THIS ONE */
56
	Mat4x4f perspective_Mat4x4f(float d);
62
	Mat4x4f perspective_Mat4x4f(float d);
57
 
63
 
58
 
64
 
59
}
65
}
60
#endif
66
#endif
61
 
67
 
62
 
68
 
63
 
69
 
64
 
70
 
65
 
71
 
66
 
72
 
67
 
73
 
68
 
74