C/acos: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
Linia 132:
#include <math.h>
// http://en.cppreference.com/w/c/numeric/math/atan2
// gcc a.c -lm -Wall
//
 
int main()
{
// normal usage: the signs of the two arguments determine the quadrant
 
// list of points (x,y) around origin in counterclockwise direction
printf("atan2( 1, 0) = %f\n", atan2( 1, 0));
double p[][2]={{ 1.0, 0.0},
printf("atan2( 1, 1) = %f\n", atan2( 1, 1));
printf("atan2( 0, 1) = %f\n", atan2( { 1.0, 0.1));},
printf("atan2(-1, 1) = %f\n", atan2( - { 1.0, 1));.0},
printf("atan2(-1, 0) = %f\n", atan2( -1 { 0.0, 1.0));},
printf("atan2(-1,-1) = %f\n", atan2( {-1.0,- 1));.0},
printf("atan2( 0,-1) = %f\n", atan2( 0, {-1));.0, 0.0},
printf("atan2( 1,-1) = %f\n", atan2( {-1.0,-0.1));},
{-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) =is atan2(y,x) 1= 0.570796000000
atan2 of point (x,y) = (1.0, 0.1) =is atan2(y,x) = 0.785398099669
atan2 of point (x,y) = (1.0, 1.0) =is atan2(y,x) = 0.000000785398
atan2 of point (-1x, 1y) = (0.0, -1.0) is atan2(y,x) = 1.785398570796
atan2 of point (x,y) = (-1.0, 1.0) =is atan2(y,x) -1= 2.570796356194
atan2 of point (-1x,y) = (-1.0, 0.0) =is atan2(y,x) -2= 3.356194141593
atan2 of point (x,y) = (-1.0, -0.1) =is atan2(y,x) = -3.141593041924
atan2 of point (x,y) = (-1.0, -1.0) =is atan2(y,x) = -2.356194
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>