Matrice inverse

Résolu
vladisback Messages postés 61 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 5 août 2008 - 25 juil. 2005 à 10:40
Aekq Messages postés 2 Date d'inscription dimanche 12 février 2006 Statut Membre Dernière intervention 15 février 2006 - 15 févr. 2006 à 14:27
bonjour, j'utilise pour mes transformation des matrices 4x3:
Xx Yx Zx Tx
Xy Yy Zy Ty
Xz Yz Zz Tz

(Identique au matrice directX excepté une quatrieme ligne dont je n'ai pas besoin)

Je voudrai savoir comment obtenir la matrice inverse, j'ai fait pas mal de recherche sur google mais n'ai trouvé que des méthodes qu'étant encore jeune et n'ayant pas encore étudié les matrices je ne comprend pas...
je voudrais donc le résultat direct pour une matrice comme celle ci.
en espérant que vous puissiez m'aider, merci d'avance.

5 réponses

vladisback Messages postés 61 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 5 août 2008
25 juil. 2005 à 13:32
c bon j'ai trouvé, voici le code si quelqu'un est interessé:


void InvMatrixFunc(double Matrix[4][4])
{

double t[6]={0,0,0,0,0,0};
double CoffactMatrix [4][4];
double td;

// calcul des cofacteurs de la ligne 1


t[0]=Matrix[2][2]*Matrix[3][3] - Matrix[3][2]*Matrix[2][3];
t[1]=Matrix[2][1]*Matrix[3][3] - Matrix[3][1]*Matrix[2][3];
t[2]=Matrix[2][1]*Matrix[3][2] - Matrix[3][1]*Matrix[2][2];
t[3]=Matrix[2][0]*Matrix[3][3] - Matrix[3][0]*Matrix[2][3];
t[4]=Matrix[2][0]*Matrix[3][2] - Matrix[3][0]*Matrix[2][2];
t[5]=Matrix[2][0]*Matrix[3][1] - Matrix[3][0]*Matrix[2][1];

CoffactMatrix[0][0]=Matrix[1][1]*t[0] - Matrix[1][2]*t[1] + Matrix[1][3]*t[2];
CoffactMatrix[0][1]=Matrix[1][0]*t[0] - Matrix[1][2]*t[3] + Matrix[1][3]*t[4];
CoffactMatrix[0][2]=Matrix[1][0]*t[1] - Matrix[1][1]*t[3] + Matrix[1][3]*t[5];
CoffactMatrix[0][3]=Matrix[1][0]*t[2] - Matrix[1][1]*t[4] + Matrix[1][2]*t[5];

// calcul du determinant

td=Matrix[0][0]*CoffactMatrix[0][0] - Matrix[0][1]*CoffactMatrix[0][1] + Matrix[0][2]*CoffactMatrix[0][2] - Matrix[0][3]*CoffactMatrix[0][3];

// Form1->Edit1->Text=FloatToStr(td);
// test du determiant : si non nul on continue

if(td==0)
{
cout<<"\ndeterminant null!!!"<<endl<<endl;

Matrix[0][0]=1;
Matrix[0][1]=0;
Matrix[0][2]=0;
Matrix[0][3]=0;
Matrix[1][0]=0;
Matrix[1][1]=1;
Matrix[1][2]=0;
Matrix[1][3]=0;
Matrix[2][0]=0;
Matrix[2][1]=0;
Matrix[2][2]=1;
Matrix[2][3]=0;
Matrix[3][0]=0;
Matrix[3][1]=0;
Matrix[3][2]=0;
Matrix[3][3]=1;

return;
}

// calcul des cofacteurs de la ligne 2
CoffactMatrix[1][0]=Matrix[0][1]*t[0] - Matrix[0][2]*t[1] + Matrix[0][3]*t[2];
CoffactMatrix[1][1]=Matrix[0][0]*t[0] - Matrix[0][2]*t[3] + Matrix[0][3]*t[4];
CoffactMatrix[1][2]=Matrix[0][0]*t[1] - Matrix[0][1]*t[3] + Matrix[0][3]*t[5];
CoffactMatrix[1][3]=Matrix[0][0]*t[2] - Matrix[0][1]*t[4] + Matrix[0][2]*t[5];

// calcul des cofacteurs de la ligne 3
t[0]=Matrix[0][2]*Matrix[1][3] - Matrix[1][2]*Matrix[0][3];
t[1]=Matrix[0][1]*Matrix[1][3] - Matrix[1][1]*Matrix[0][3];
t[2]=Matrix[0][1]*Matrix[1][2] - Matrix[1][1]*Matrix[0][2];
t[3]=Matrix[0][0]*Matrix[1][3] - Matrix[1][0]*Matrix[0][3];
t[4]=Matrix[0][0]*Matrix[1][2] - Matrix[1][0]*Matrix[0][2];
t[5]=Matrix[0][0]*Matrix[1][1] - Matrix[1][0]*Matrix[0][1];

CoffactMatrix[2][0] =Matrix[3][1]*t[0] - Matrix[3][2]*t[1] + Matrix[3][3]*t[2];
CoffactMatrix[2][1] =Matrix[3][0]*t[0] - Matrix[3][2]*t[3] + Matrix[3][3]*t[4];
CoffactMatrix[2][2]=Matrix[3][0]*t[1] - Matrix[3][1]*t[3] + Matrix[3][3]*t[5];
CoffactMatrix[2][3]=Matrix[3][0]*t[2] - Matrix[3][1]*t[4] + Matrix[3][2]*t[5];

// calcul des cofacteurs de la ligne 4
CoffactMatrix[3][0]=Matrix[2][1]*t[0] - Matrix[2][2]*t[1] + Matrix[2][3]*t[2];
CoffactMatrix[3][1]=Matrix[2][0]*t[0] - Matrix[2][2]*t[3] + Matrix[2][3]*t[4];
CoffactMatrix[3][2]=Matrix[2][0]*t[1] - Matrix[2][1]*t[3] + Matrix[2][3]*t[5];
CoffactMatrix[3][3]=Matrix[2][0]*t[2] - Matrix[2][1]*t[4] + Matrix[2][2]*t[5];

// inversion
td=1/td;
Matrix[0][0]=CoffactMatrix[0][0]*td;
Matrix[0][1]=-CoffactMatrix[1][0]*td;
Matrix[0][2]=CoffactMatrix[2][0]*td;
Matrix[0][3]=-CoffactMatrix[3][0]*td;
Matrix[1][0]=-CoffactMatrix[0][1]*td;
Matrix[1][1]=CoffactMatrix[1][1]*td;
Matrix[1][2]=-CoffactMatrix[2][1]*td;
Matrix[1][3]=CoffactMatrix[3][1]*td;
Matrix[2][0]=CoffactMatrix[0][2]*td;
Matrix[2][1]=-CoffactMatrix[1][2]*td;
Matrix[2][2]=CoffactMatrix[2][2]*td;
Matrix[2][3]=-CoffactMatrix[3][2]*td;
Matrix[3][0]=-CoffactMatrix[0][3]*td;
Matrix[3][1]=CoffactMatrix[1][3]*td;
Matrix[3][2]=-CoffactMatrix[2][3]*td;
Matrix[3][3]=CoffactMatrix[3][3]*td;

return;
}


source originale:
http://forum.hardware.fr/hardwarefr/Programmation/Inverse-matrice-sujet-27393-2.htm
3
vladisback Messages postés 61 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 5 août 2008
25 juil. 2005 à 10:43
Aie désolé j'avais cherché sur google mais pas sur le site et jvois qu'il y a pas mal de choses la dessus et je pense y trouvé mon bonheur.
merci quand meme et encore désolé
0
cosmobob Messages postés 700 Date d'inscription mardi 30 décembre 2003 Statut Membre Dernière intervention 27 janvier 2009 4
25 juil. 2005 à 11:19
salut,

est ce que tu te rends compte que tu veux inverser une matrice qui est pas carrée?



a+
0
vladisback Messages postés 61 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 5 août 2008
25 juil. 2005 à 13:06
oui oui je sai, mais en fait je vais utiliser une 4x4, par contre j'ai regardé les exemples sur ce site sa a l'air plutot chiant (les exemples font avec des matrices de n'importe quel taille) donc si quelqu'un a un exemple juste pour les 4x4 je suis preneur, merci!

PS: les inversion de matrices non carrée sa existe (si si chercher bien sa existe) mais c'est extrémement difficile a réaliser.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Aekq Messages postés 2 Date d'inscription dimanche 12 février 2006 Statut Membre Dernière intervention 15 février 2006
15 févr. 2006 à 14:27
Salut,
J'ai lu votre demande de recherche de code d'inversion de matrice;
Je porte à ta connaissance que mathématiquement l'inversion n'est possible que pour des matrice carrées.
Cordiallement
0
Rejoignez-nous