mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
set initial value to avoid error
This commit is contained in:
parent
d186f59144
commit
d1dfde4f89
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
void to_polar(double x, double y, double *r, double *theta)
|
void to_polar(double x, double y, double *r, double *theta)
|
||||||
{
|
{
|
||||||
double thetaFinal;
|
double thetaFinal = 0.f;
|
||||||
|
|
||||||
*r = sqrt(x * x + y * y);
|
*r = sqrt(x * x + y * y);
|
||||||
|
|
||||||
@ -46,9 +46,13 @@ void to_polar(double x, double y, double *r, double *theta)
|
|||||||
{ // Q4
|
{ // Q4
|
||||||
thetaFinal = 2 * M_PI - *theta;
|
thetaFinal = 2 * M_PI - *theta;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Should not reach here!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x == 0)
|
else
|
||||||
{ // exceptions when no actual angle is present
|
{ // exceptions when no actual angle is present
|
||||||
if (y > 0)
|
if (y > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user