Explication d'un programme C++
Bonjour,
svp est ce que quelqu'un peut m'expliquer c'est 2 fonction
float point::theta()
{
const double pi=3.14;
float teta;
teta=atan(y/x);
teta =x?atan(y/x):(pi/2);
if (y<0 && x>0)
{
teta=(2*pi)+teta;
}
if(y<0 && x<0)
{
teta=pi+teta;
}
return(teta);
}
************************************************************
void point::rotation(float teta)
{
float c;float Teta;
c=sqrt((x*x)+(y*y));
teta=theta();
teta=teta+Teta;
x=c*cos(teta);
y=c*sin(teta);
}
svp est ce que quelqu'un peut m'expliquer c'est 2 fonction
float point::theta()
{
const double pi=3.14;
float teta;
teta=atan(y/x);
teta =x?atan(y/x):(pi/2);
if (y<0 && x>0)
{
teta=(2*pi)+teta;
}
if(y<0 && x<0)
{
teta=pi+teta;
}
return(teta);
}
************************************************************
void point::rotation(float teta)
{
float c;float Teta;
c=sqrt((x*x)+(y*y));
teta=theta();
teta=teta+Teta;
x=c*cos(teta);
y=c*sin(teta);
}
2 réponses
-
ben c'est des maths, de la géométrie vectorielle.
la première fonction theta donne l'angle trigo de ton vecteur (entre 0 et 2*pi, si j'ai bien compris)
la deuxième, et bien je ne comprends pas trop ce qu'elle fait, d'après son nom elle devrait tourner le vecteur d'un certain angle, mais il me semble qu'elle contient une erreur : elle utilise une variable Teta (avec majuscule) qui n'est pas initialisée.
Es-tu sûr de l'avoir copiée correctement ? -
svp est ce que quelqu'un peut repondre a ma question