C/acos: Różnice pomiędzy wersjami
Usunięta treść Dodana treść
m →Przykład użycia: atan2 |
m →Przykład użycia: nowy kod |
||
Linia 132:
#include <math.h>
// http://en.cppreference.com/w/c/numeric/math/atan2
// gcc a.c -lm -Wall
int main()
{
// list of points (x,y) around origin in counterclockwise direction
double p[][2]={{ 1.0, 0.0},
{-1.0,-1.0},
{ 0.0,-1.0},
{ 1.0,-1.0},
{ 1.0,-0.1}};
int length = sizeof(p)/sizeof(p[0]);
int i;
for ( i=0; i<length; i++){
//atan2(y,x) , result = the arc tangent of y/x in the range [-π ; +π] radians
printf ("atan2 of point (x,y) = (%.1f, %.1f) is atan2(y,x) = %f\n", p[i][0], p[i][1], atan2(p[i][1], p[i][0]));
}
Linia 153 ⟶ 173:
return 0;
}▼
▲}
</source>
Linia 161 ⟶ 181:
<pre>
atan2 of point (x,y) = (1.0, 0.0)
atan2 of point (x,y) = (1.0, 0.1)
atan2 of point (x,y) = (1.0, 1.0)
atan2 of point (
atan2 of point (x,y) = (-1.0, 1.0)
atan2 of point (
atan2 of point (x,y) = (-1.0, -0.1)
atan2 of point (x,y) = (-1.0, -1.0)
atan2 of point (x,y) = (0.0, -1.0) is atan2(y,x) = -1.570796
atan2 of point (x,y) = (1.0, -1.0) is atan2(y,x) = -0.785398
atan2 of point (x,y) = (1.0, -0.1) is atan2(y,x) = -0.099669
</pre>
|