kopia lustrzana https://gitlab.com/Zwarf/picplanner
transformations: Prefer atan2() to avoid special cases
This simplifies the code and also avoid the equality check for floating numbers. ../src/calculations/calculations_transformations.c: In function ‘picplanner_transform_rotational_to_horizontal’: ../src/calculations/calculations_transformations.c:202:14: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal] 202 | else if (x == 0 && y < 0) | ^~ ../src/calculations/calculations_transformations.c:204:14: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal] 204 | else if (x == 0 && y > 0) | ^~main
rodzic
0c627b0e7f
commit
29c660af5e
|
@ -193,18 +193,7 @@ double
|
|||
|
||||
y = cos (declination) * sin (time_sidereal - right_ascension);
|
||||
|
||||
if (x < 0 && y <= 0)
|
||||
azimuth = atan (y / x);
|
||||
else if (x < 0 && y > 0)
|
||||
azimuth = atan (y / x) + 2 * M_PI;
|
||||
else if (x > 0)
|
||||
azimuth = atan (y / x) + M_PI;
|
||||
else if (x == 0 && y < 0)
|
||||
azimuth = M_PI / 2;
|
||||
else if (x == 0 && y > 0)
|
||||
azimuth = -3 * M_PI / 2;
|
||||
else
|
||||
azimuth = 0;
|
||||
azimuth = atan2 (y, x);
|
||||
|
||||
elevation = asin (sin (latitude) * sin (declination)
|
||||
+ cos (latitude) * cos (declination) * cos (time_sidereal - right_ascension));
|
||||
|
|
Ładowanie…
Reference in New Issue