The function hypot is available in C99 and has the potential to compute the same
operation more efficiently and with greater precision.
#include "common.h"
#include "g.h"
#include "gcommon.h"
+#include <math.h>
#include <string.h>
#define WCU widget->u.c
if (pd.x == 0 && pd.y == 0)
return 0;
tangent = atan2((double) pd.y, (double) pd.x);
- if ((l = sqrt((double) (pd.x * pd.x + pd.y * pd.y))) > 30)
+ if ((l = hypot(pd.x, pd.y)) > 30)
l = 30;
pa.x = l * cos(tangent + M_PI / 7) + pp2.x;
pa.y = l * sin(tangent + M_PI / 7) + pp2.y;
#include "g.h"
#include "gcommon.h"
#include "mem.h"
+#include <math.h>
#include <string.h>
#define WCU widget->u.c
if (pd.x == 0 && pd.y == 0)
return 0;
tangent = atan2 ((double) pd.y, (double) pd.x);
- if ((l = sqrt ((double) (pd.x * pd.x + pd.y * pd.y))) > 30)
+ if ((l = hypot(pd.x, pd.y)) > 30)
l = 30;
pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
pa.y = l * sin (tangent + M_PI / 7) + pp2.y;
#include "g.h"
#include "gcommon.h"
#include "mem.h"
+#include <math.h>
#include <string.h>
#define WPU widget->u.p
if (pd.x == 0 && pd.y == 0)
return 0;
tangent = atan2 ((double) pd.y, (double) pd.x);
- if ((l = sqrt ((double) (pd.x * pd.x + pd.y * pd.y))) > 30)
+ if ((l = hypot(pd.x, pd.y)) > 30)
l = 30;
pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
pa.y = l * sin (tangent + M_PI / 7) + pp2.y;
#ifdef FEATURE_GMAP
#include <gmap.h>
#endif
+#include <math.h>
#include <string.h>
#define WCU widget->u.c
if (pd.x == 0 && pd.y == 0)
return 0;
tangent = atan2 ((double) pd.y, (double) pd.x);
- if ((l = sqrt ((double) (pd.x * pd.x + pd.y * pd.y))) > 30)
+ if ((l = hypot(pd.x, pd.y)) > 30)
l = 30;
pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
pa.y = l * sin (tangent + M_PI / 7) + pp2.y;
#include "g.h"
#include "gcommon.h"
#include "mem.h"
+#include <math.h>
#include <string.h>
#define PSDPI 300.0
if (pd.x == 0 && pd.y == 0)
return 0;
tangent = atan2 ((double) pd.y, (double) pd.x);
- if ((l = sqrt ((double) (pd.x * pd.x + pd.y * pd.y))) < 30)
+ if ((l = hypot(pd.x, pd.y)) < 30)
l = 30;
pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
pa.y = l * sin (tangent + M_PI / 7) + pp2.y;