Skip to content

Commit

Permalink
set initial value to avoid error
Browse files Browse the repository at this point in the history
  • Loading branch information
kvedala committed Jul 11, 2020
1 parent d186f59 commit d1dfde4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions misc/cartesian_to_polar.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
void to_polar(double x, double y, double *r, double *theta)
{
double thetaFinal;
double thetaFinal = 0.f;

*r = sqrt(x * x + y * y);

Expand All @@ -46,9 +46,13 @@ void to_polar(double x, double y, double *r, double *theta)
{ // Q4
thetaFinal = 2 * M_PI - *theta;
}
else
{
fprintf(stderr, "Should not reach here!\n");
}
}
}
if (x == 0)
else
{ // exceptions when no actual angle is present
if (y > 0)
{
Expand Down

0 comments on commit d1dfde4

Please sign in to comment.