aboutsummaryrefslogtreecommitdiff
path: root/generic/OverlapMan.c
diff options
context:
space:
mode:
authorlecoanet2000-03-07 14:56:40 +0000
committerlecoanet2000-03-07 14:56:40 +0000
commit0df054ba48c932b9e753dbc5c75978a5a36bbc60 (patch)
treeeabda8387b6c0c2865f4311c48370b767de0684d /generic/OverlapMan.c
parentf9c90ae9f4811bf576cec6bb512e67859b8c8620 (diff)
downloadtkzinc-0df054ba48c932b9e753dbc5c75978a5a36bbc60.zip
tkzinc-0df054ba48c932b9e753dbc5c75978a5a36bbc60.tar.gz
tkzinc-0df054ba48c932b9e753dbc5c75978a5a36bbc60.tar.bz2
tkzinc-0df054ba48c932b9e753dbc5c75978a5a36bbc60.tar.xz
* Utilisation de ZnMalloc et consorts.
* Sortie des functions de conversion d'angles vers Geo.h.
Diffstat (limited to 'generic/OverlapMan.c')
-rw-r--r--generic/OverlapMan.c76
1 files changed, 12 insertions, 64 deletions
diff --git a/generic/OverlapMan.c b/generic/OverlapMan.c
index e986efa..4f062fb 100644
--- a/generic/OverlapMan.c
+++ b/generic/OverlapMan.c
@@ -40,6 +40,8 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#include "OverlapMan.h"
+#include "Types.h"
+#include "Geo.h"
#include <stdio.h>
#include <string.h>
@@ -147,27 +149,6 @@ static double placing_step = M_PI/6.0;
/*
****************************************************************************
*
- * Mrealloc --
- * Dynamic allocation/reallocation of 'size' bytes
- *
- ****************************************************************************
- */
-static void *
-Mrealloc(void *p,
- unsigned int size)
-{
- if (p != NULL) {
- return realloc(p, size);
- }
- else {
- return malloc(size);
- }
-}
-
-
-/*
- ****************************************************************************
- *
* FindPosW --
* Find the zinc position in the database,
* if not found, gets the positon to insert in.
@@ -230,7 +211,7 @@ AllocW(void *w,
if (NBzincs == NBalloc_zincs) {
NBalloc_zincs += NB_ALLOC;
- wr = (ZINCS *) Mrealloc((void *) wr, sizeof(ZINCS) * NBalloc_zincs);
+ wr = (ZINCS *) ZnRealloc((void *) wr, sizeof(ZINCS) * NBalloc_zincs);
}
for (i = NBzincs-1; i >= pos; i--) {
@@ -283,39 +264,6 @@ ProjToAngle(int dx,
/*
- ******************************************************************************
- *
- * RadiansToDegrees --
- * Transform an angle from radian to degrees in the range [0, 359].
- *
- ******************************************************************************
- */
-static int
-RadiansToDegrees(double x)
-{
- int i;
-
- i = (int) (x * 180.0 / M_PI);
- return (i % 360 + 360) % 360;
-}
-
-
-/*
- ******************************************************************************
- *
- * DegreesToRadians --
- * Transform an angle from degrees in the range [0, 359] to radians.
- *
- ******************************************************************************
- */
-static double
-DegreesToRadians(int x)
-{
- return ((double) x) * M_PI / 180.0;
-}
-
-
-/*
****************************************************************************
*
* OmRegister --
@@ -357,7 +305,7 @@ OmUnregister(void *w)
int i;
if (FindPosW(w, &i) == TRUE) {
- free(wr[i].infos);
+ ZnFree(wr[i].infos);
memcpy((char *) &wr[i], (char *) &wr[i+1], (NBzincs-i-1)*sizeof(ZINCS));
NBzincs--;
}
@@ -472,8 +420,8 @@ PutTrackLoaded(int iw)
*/
if (wr[iw].NBinfos == wr[iw].NBalloc_infos) {
wr[iw].NBalloc_infos += NB_ALLOC;
- wr[iw].infos = (INFOS *) Mrealloc((void *) wr[iw].infos,
- sizeof(INFOS)*wr[iw].NBalloc_infos);
+ wr[iw].infos = (INFOS *) ZnRealloc((void *) wr[iw].infos,
+ sizeof(INFOS)*wr[iw].NBalloc_infos);
}
if (pos < wr[iw].NBinfos) {
@@ -529,7 +477,7 @@ ReadTracks(int iw)
&info1.rho, &info1.theta,
&info1.visibility))) {
info1.alpha = (ProjToAngle(info1.vv_dx, info1.vv_dy ) - M_PI_2 +
- DegreesToRadians(info1.theta));
+ DegreesToRadian(info1.theta));
info1.dx = (int) info1.rho * cos(info1.alpha);
info1.dy = (int) info1.rho * sin(info1.alpha);
info1.Refresh = TRUE;
@@ -982,11 +930,11 @@ OmProcessOverlap(void *zinc,
}
wr[iw].infos[ip].alpha += wr[iw].infos[ip].alpha_point * DELTA_T ;
- wr[iw].infos[ip].theta = RadiansToDegrees(wr[iw].infos[ip].alpha -
- ProjToAngle(wr[iw].infos[ip].vv_dx,
- wr[iw].infos[ip].vv_dy)
- + M_PI_2);
-
+ wr[iw].infos[ip].theta = (int) RadianToDegrees360(wr[iw].infos[ip].alpha -
+ ProjToAngle(wr[iw].infos[ip].vv_dx,
+ wr[iw].infos[ip].vv_dy)
+ + M_PI_2);
+
/*
if (wr[iw].infos[ip].theta > 75 && wr[iw].infos[ip].theta < 105) {
if (wr[iw].infos[ip].alpha_point > 0) {