Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef GG_H
00029
00030 #define GG_H 1
00031
00032
00033
00034
00035
00036 typedef struct Point2Struct {
00037 double x, y;
00038 } Point2;
00039 typedef Point2 Vector2;
00040
00041 typedef struct IntPoint2Struct {
00042 int x, y;
00043 } IntPoint2;
00044
00045 typedef struct Matrix3Struct {
00046 double element[3][3];
00047 } Matrix3;
00048
00049 typedef struct Box2dStruct {
00050 Point2 min, max;
00051 } Box2;
00052
00053
00054
00055
00056
00057
00058 typedef struct Point3Struct {
00059 double x, y, z;
00060 } Point3;
00061 typedef Point3 Vector3;
00062
00063 typedef struct IntPoint3Struct {
00064 int x, y, z;
00065 } IntPoint3;
00066
00067
00068 typedef struct Matrix4Struct {
00069 double element[4][4];
00070 } Matrix4;
00071
00072 typedef struct Box3dStruct {
00073 Point3 min, max;
00074 } Box3;
00075
00076
00077
00078
00079
00080
00081
00082
00083 #define ABS(a) (((a)<0) ? -(a) : (a))
00084
00085
00086 #define ROUND(a) ((a)>0 ? (int)((a)+0.5) : -(int)(0.5-(a)))
00087
00088
00089 #define ZSGN(a) (((a)<0) ? -1 : (a)>0 ? 1 : 0)
00090
00091
00092 #define SGN(a) (((a)<0) ? -1 : 1)
00093
00094
00095 #define ASSERT(x) \
00096 if (!(x)) fprintf(stderr," Assert failed: x\n");
00097
00098
00099 #define SQR(a) ((a)*(a))
00100
00101
00102
00103
00104
00105
00106
00107 #define MIN(a,b) (((a)<(b))?(a):(b))
00108
00109
00110 #define MAX(a,b) (((a)>(b))?(a):(b))
00111
00112
00113 #define SWAP(a,b) { a^=b; b^=a; a^=b; }
00114
00115
00116
00117 #define LERP(a,l,h) ((l)+(((h)-(l))*(a)))
00118
00119
00120 #define CLAMP(v,l,h) ((v)<(l) ? (l) : (v) > (h) ? (h) : v)
00121
00122
00123
00124
00125
00126
00127
00128 #define NEWSTRUCT(x) (struct x *)(malloc((unsigned)sizeof(struct x)))
00129
00130
00131 #define NEWTYPE(x) (x *)(malloc((unsigned)sizeof(x)))
00132
00133
00134
00135
00136
00137
00138 #define PI 3.141592
00139 #define PITIMES2 6.283185
00140 #define PIOVER2 1.570796
00141 #define E 2.718282
00142 #define SQRT2 1.414214
00143 #define SQRT3 1.732051
00144 #define GOLDEN 1.618034
00145 #define DTOR 0.017453
00146 #define RTOD 57.29578
00147
00148
00149
00150
00151
00152
00153 #define TRUE 1
00154 #define FALSE 0
00155 #define ON 1
00156 #define OFF 0
00157 typedef int boolean;
00158 typedef boolean flag;
00159
00160 extern double V2SquaredLength(), V2Length();
00161 extern double V2Dot(), V2DistanceBetween2Points();
00162 extern Vector2 *V2Negate(), *V2Normalize(), *V2Scale(), *V2Add(), *V2Sub();
00163 extern Vector2 *V2Lerp(), *V2Combine(), *V2Mul(), *V2MakePerpendicular();
00164 extern Vector2 *V2New(), *V2Duplicate();
00165 extern Point2 *V2MulPointByMatrix();
00166 extern Matrix3 *V2MatMul();
00167
00168 extern double V3SquaredLength(), V3Length();
00169 extern double V3Dot(), V3DistanceBetween2Points();
00170 extern Vector3 *V3Normalize(), *V3Scale(), *V3Add(), *V3Sub();
00171 extern Vector3 *V3Lerp(), *V3Combine(), *V3Mul(), *V3Cross();
00172 extern Vector3 *V3New(), *V3Duplicate();
00173 extern Point3 *V3MulPointByMatrix();
00174 extern Matrix4 *V3MatMul();
00175
00176 extern double RegulaFalsi(), NewtonRaphson(), findroot();
00177
00178 #endif