Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1664 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/* CVS :        $Id: fab_tool.h,v 1.1 2004-07-05 14:39:42 pj Exp $ */
22
 
23
/*
24
 * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
25
 *
26
 * This program is free software; you can redistribute it and/or modify
27
 * it under the terms of the GNU General Public License as published by
28
 * the Free Software Foundation; either version 2 of the License, or
29
 * (at your option) any later version.
30
 *
31
 * This program is distributed in the hope that it will be useful,
32
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34
 * GNU General Public License for more details.
35
 *
36
 * You should have received a copy of the GNU General Public License
37
 * along with this program; if not, write to the Free Software
38
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
39
 *
40
 */
41
 
42
/****************************************************
43
 *                                                  *
44
 *  file:        FAB_tool.h                         *
45
 *  libreria:    FAB_LIB                            *
46
 *  version:     1.0 25/08/2002                     *
47
 *  creato da:   Fabio CALABRESE                    *
48
 *                                                  *
49
 ****************************************************
50
 *                                                  *
51
 *  descrizione: tool di funzioni d'utilita'        *
52
 *                                                  *
53
 ****************************************************/
54
 
55
#ifndef __FAB_LIB__FAB_tool_h__
56
#define __FAB_LIB__FAB_tool_h__
57
//-------------------BEGIN---------------------------
58
 
59
// *** Librerie S.Ha.R.K ***
60
// *** Librerie Standard C ***
61
#include <stdlib.h>
62
#include <math.h>
63
// *** Librerie FAB ***
64
 
65
// -----------
66
// Definizioni
67
//----------------------
68
//----------------------
69
 
70
// ----------------
71
// Funzioni & Macro
72
//-------------------------------------------------
73
#define FAB_PI                           3.141592654
74
#define FAB_grad(RADIANTI)               RADIANTI/FAB_PI*180
75
#define FAB_rad(GRADI)                   GRADI/180.0*FAB_PI
76
#define FAB_set_ang360(ANGOLO,X,Y)       if ((X)>0) {if((Y)>0) (ANGOLO)=atan((Y)/(double)(X));else if((Y)<0) (ANGOLO)=atan((Y)/(double)(X))+2*FAB_PI;else (ANGOLO)=0;}else if ((X)<0) (ANGOLO)=atan((Y)/(double)(X))+FAB_PI;else /* X==0 */if ((Y)>0) (ANGOLO)=FAB_PI/2;else if ((Y)<0) (ANGOLO)=FAB_PI/2+FAB_PI;else /* Y==0 */ (ANGOLO)=-1; /* X=Y=0 */
77
#define FAB_set_xy360(X,Y,MODULO,ANGOLO) (X)=(MODULO)*cos(ANGOLO);(Y)=(MODULO)*sin(ANGOLO);
78
 
79
#define FAB_ABS(X)               ((X) > 0 ? (X) : (X)*-1)
80
 
81
#define FAB_sign_rand()          (rand()%2 ? -1 : +1)
82
#define FAB_int_rand(MIN,MAX )   ((MIN) + rand()%((MAX)-(MIN)+1))
83
#define FAB_double_rand(MIN,MAX) ((MIN) + ((MAX)-(MIN))*((double)rand()/RAND_MAX))
84
//--------------------------------------------------
85
 
86
 
87
// Altro...
88
 
89
//----------------------END--------------------------
90
#endif