mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-25 14:59:36 +03:00
fix lgtm alert - variable pi
This commit is contained in:
parent
81f4428569
commit
df25df3236
@ -1,8 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Function to convert a Cartesian co-ordinate to polar form.
|
||||
*/
|
||||
#define _USE_MATH_DEFINES /**< required for MS Visual C */
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const double pi = 3.141592653589793238462643383279502884;
|
||||
|
||||
/**
|
||||
give as arguments to the executable two x and y coordinates
|
||||
outputs a polar coordinate
|
||||
@ -24,15 +27,15 @@ int main()
|
||||
}
|
||||
else if (x < 0 && y > 0)
|
||||
{ // Q2
|
||||
thetaFinal = theta + pi;
|
||||
thetaFinal = theta + M_PI;
|
||||
}
|
||||
else if (x < 0 && y < 0)
|
||||
{ // Q3
|
||||
thetaFinal = theta - pi;
|
||||
thetaFinal = theta - M_PI;
|
||||
}
|
||||
else if (x > 0 && y < 0)
|
||||
{ // Q4
|
||||
thetaFinal = 2 * pi - theta;
|
||||
thetaFinal = 2 * M_PI - theta;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,11 +43,11 @@ int main()
|
||||
{ // exceptions when no actual angle is present
|
||||
if (y > 0)
|
||||
{
|
||||
thetaFinal = pi / 2;
|
||||
thetaFinal = M_PI / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
thetaFinal = -(pi / 2);
|
||||
thetaFinal = -(M_PI / 2);
|
||||
}
|
||||
}
|
||||
if (y == 0)
|
||||
@ -55,7 +58,7 @@ int main()
|
||||
}
|
||||
else
|
||||
{
|
||||
thetaFinal = -pi;
|
||||
thetaFinal = -M_PI;
|
||||
}
|
||||
}
|
||||
printf("%.2f %.2f\n", r, atan2(y, x));
|
||||
|
Loading…
Reference in New Issue
Block a user