TODO update
[Lilanci.git] / geometry.h
blobe4d8b3022f9ad1764466dbe6dedc6b9feaa83571
1 #ifndef GEOMETRY_H_G
2 #define GEOMETRY_H_G
4 typedef struct {
5 double x,y;
6 } Vect;
8 typedef struct {
9 Vect *v; //vertexs
10 Vect *n; //normal's for loines between v[i] and v[i+1]
11 double *a; //dot products
12 int novec;
13 int alloc;
14 } Poly;
16 double DotProduct(Vect *a, Vect *b);
17 void NormV(Vect *v);
19 int InPoly(Poly *p, Vect *v);
20 Poly *NewPoly();
21 int AddToPoly(Poly *p,Vect *v);
22 int AddToPolyXY(Poly *p, double x, double y);
23 void FreePoly(Poly *p);
24 Poly *NewRect(double x, double y, double xx, double yy);
25 int PolyInPoly(Poly *p1, Poly *p2); //does they intersect?
26 int PolyInPolyComp(Poly *p1, Poly *p2); // is one completely inside another? 0 no 1 first in second 2 second in first
27 Poly *TranslatePolyXY(Poly *p, double x, double y); //returns translated copy of Poly
28 Poly *TranslatePoly(Poly *p, Vect *v); //returns translated copy of Poly
29 void MultiplyPoly(Poly *p, double xm, double ym);
30 void PrintPoly(Poly *p);
31 void PrintVect(Vect *a);
32 char *Poly2String(Poly *p);
33 void FreePoly2String(char *s);
34 Poly *String2Poly(char *s);
36 typedef struct{
37 int nopol;
38 Poly **p;
39 } Area;
41 Area *NewArea();
42 void FreeArea(Area *a);
43 int AddToArea(Area *a, Poly *p);
44 int InArea(Area *a, Vect *v);
45 int AreaInArea(Area *a1, Area *a2); //does they intersect?
46 int AreaInAreaComp(Area *a1, Area *a2); // is one completely inside another? 0 no 1 first in second 2 second in first
47 Area *TranslateAreaXY(Area *a, double x, double y); //returns translated copy of Area
48 Area *TranslateArea(Area *a, Vect *v); //returns translated copy of Area
49 void MultiplyArea(Area *p, double xm, double ym);
50 void PrintArea(Area *a);
51 char *Area2String(Area *a);
52 void FreeArea2String(char *s);
53 Area *String2Area(char *s);
54 #endif //GEOMETRY_H_G