7.1.6 Les opérateurs sur la Matrice4

Il est temps de définir les opérateurs de la Matrice4 :

1
2
3
4
5
6
7
Matrice4 & operator = (const Matrice4 & other);
Matrice4 & operator - ();
Matrice4 & operator -= (const Matrice4 & other);
Matrice4 & operator += (const Matrice4 & other);
Matrice4 & operator *= (const Matrice4 & other);
Matrice4 & operator *= (float nb);
Matrice4 & operator /= (float nb);

On les ajoutes :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef ___Matrice4_H__
#define ___Matrice4_H__
#include <math.h>
#include <iostream>
#include "Vecteur4.h"

void produitVectoriel(float & x, float & y, float & z, float x1, float y1, float z1, float x2, float y2, float z2);
void normaliseVecteur(float & x, float & y, float & z);

class Matrice4{
	public:
		Matrice4();
		Matrice4(const Vecteur4 & v1, const Vecteur4 & v2, const Vecteur4 & v3, const Vecteur4 & v4);
		Matrice4(float x1, float y1, float z1, float t1,
			float x2, float y2, float z2, float t2,
			float x3, float y3, float z3, float t3,
			float x4, float y4, float z4, float t4
		);
		Matrice4(const Matrice4 & other);
		virtual ~Matrice4();
		
		void setMatrice4(const Vecteur4 & v1, const Vecteur4 & v2, const Vecteur4 & v3, const Vecteur4 & v4);
		void setMatrice4(float x1, float y1, float z1, float t1,
			float x2, float y2, float z2, float t2,
			float x3, float y3, float z3, float t3,
			float x4, float y4, float z4, float t4
		);
		
		void loadIdentity();
		void loadNull();
		void translated(float x, float y, float z);
		void scale(float x, float y, float z);
		void rotateRad(float angle, float x, float y, float z);
		void rotateDeg(float angle, float x, float y, float z);
		void perspectiveRad(float angle, float ratio, float near, float far);
		void perspectiveDeg(float angle, float ratio, float near, float far);
		void lookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ);
		
		bool push();
		bool pop();
		void depiler();
		
		float * getValue() const;
		
		//Les opérateurs de la classe Matrice4
		Matrice4 & operator = (const Matrice4 & other);
		Matrice4 & operator - ();
		Matrice4 & operator -= (const Matrice4 & other);
		Matrice4 & operator += (const Matrice4 & other);
		Matrice4 & operator *= (const Matrice4 & other);
		Matrice4 & operator *= (float nb);
		Matrice4 & operator /= (float nb);
};

#endif //classe Matrice4

On n'en a pas encore fini avec les opérateurs.