Mathc matrices/c25k
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c05b.c |
---|
/* ------------------------------------ */
/* Save as : c05b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RCQ RC3
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double tu[RCQ*C1]={
-7,
-6,
+8
};
double tv[RCQ*C1]={
-5,
-4,
+7
};
double tQ[RCQ*RCQ]={
+0.4819, +0.4615, +0.7448,
+0.6196, -0.7806, +0.0828,
+0.6196, +0.4216, -0.6621
};
double **u = ca_A_mR(tu,i_mR(RCQ,C1));
double **v = ca_A_mR(tv,i_mR(RCQ,C1));
double **Q = ca_A_mR(tQ,i_mR(RCQ,RCQ));
double **Qu = mul_mR(Q,u,i_mR(RCQ,C1));
double **Qv = mul_mR(Q,v,i_mR(RCQ,C1));
clrscrn();
printf(" Cosine of the Angle Between Vectors U and V :\n\n");
printf(" u :");
p_mR(u,S3,P0,C6);
printf(" v :");
p_mR(v,S3,P0,C6);
printf(" <u,v> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n\n\n",
dot_R(u,v)
/
( norm_R(u) * norm_R(v) ));
stop();
clrscrn();
printf(" Q :");
p_mR(Q,S3,P4,C6);
stop();
clrscrn();
printf(" Cosine of the Angle Between Vectors U and V :\n\n");
printf(" Qu :");
p_mR(Qu,S3,P4,C6);
printf(" Qv :");
p_mR(Qv,S3,P4,C6);
printf(" <Qu,Qv> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n",
dot_R(Qu,Qv)
/
( norm_R(u) * norm_R(v) ));
stop();
clrscrn();
printf(" Cosine of the Angle Between Vectors U and V :\n\n");
printf(" <u,v> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n\n\n",
dot_R(u,v)
/
( norm_R(u) * norm_R(v) ));
printf(" <Qu,Qv> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n",
dot_R(Qu,Qv)
/
( norm_R(u) * norm_R(v) ));
f_mR(u);
f_mR(v);
f_mR(Qu);
f_mR(Qv);
f_mR(Q);
}
/* ------------------------------------ */
int main(void)
{
fun();
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Vérifions que multiplier deux vecteurs par une matrice orthonormale ne change pas leurs angles :
Exemple de sortie écran :
--------------------------------
Cosine of the Angle Between Vectors U and V :
u :
-7
-6
+8
v :
-5
-4
+7
<u,v>
cos(alpha) = ----------- = +0.9931
||u|| ||v||
Press return to continue.
--------------------------------
Q :
+0.4819 +0.4615 +0.7448
+0.6196 -0.7806 +0.0828
+0.6196 +0.4216 -0.6621
Press return to continue.
--------------------------------
Cosine of the Angle Between Vectors U and V :
Qu :
-0.1839
+1.0088
-12.1636
Qv :
+0.9581
+0.6040
-9.4191
<Qu,Qv>
cos(alpha) = ----------- = +0.9931
||u|| ||v||
Press return to continue.
--------------------------------
Cosine of the Angle Between Vectors U and V :
<u,v>
cos(alpha) = ----------- = +0.9931
||u|| ||v||
<Qu,Qv>
cos(alpha) = ----------- = +0.9931
||u|| ||v||