/*************************************************************************************************************************************/ /* */ /* T E S T D U C A L C U L D E S M O M E N T S D ' I N E R T I E : */ /* */ /* */ /* Author of '$xtc/inertie.11$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20230825171359). */ /* */ /*************************************************************************************************************************************/ #include <stdio.h> #define Xmin (-20) #define Xmax (+50) #define Ymin (-40) #define Ymax (+30) int main() { double x,y; double n=0; double xG=0,yG=0; double Ixx=0,Ixy=0,Iyx=0,Iyy=0; for (y=Ymin ; y<=Ymax ; y++) { for (x=Xmin ; x<=Xmax ; x++) { n++; xG = xG+x; yG = yG+y; } } xG = xG/n; yG = yG/n; for (y=Ymin ; y<=Ymax ; y++) { for (x=Xmin ; x<=Xmax ; x++) { Ixx = (x-xG)*(x-xG); Ixy = (x-xG)*(y-yG); Iyx = (y-yG)*(x-xG); Iyy = (y-yG)*(y-yG); } } if (Ixy != Iyx) { fprintf(stderr,"Les moments d'inertie 'Ixy=%+f' et 'Iyx=%+f' sont differents.\n",Ixy,Iyx); } else { } printf("NombrePoints=%d\n",(int)n); printf("MatriceInertie={{%+f,%+f},{%+f,%+f}}\n",Ixx,Ixy,Iyx,Iyy); }