1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include <stdio.h>
#include <stdlib.h>
/*
* L'idee est de pouvoir calculer les intersections
* de la facon la plus simple possible
* je pense a une matrice
* L'intersection existe lorsque 4 extremites forment un rectangle
* Il y a un rectangle de differentes orientations
* Le plus rapide c'est le calcul de la matrice
* et sa representation
* La matrice pour 1 segment:
* x1 x2
* y1
* y2
* La matrice pour 2 segments:
* x11 x12 x21 x22
* y11 x
* y12 x
* y21 x
* y22 x
* Si on trie les x et les y
*
* x11 x21 x12 x22
* y22 x
* y12 x
* y21 x
* y11 x
* Une fois tries l'ordre determine s'il y a intersection ou non
* Le chemin le plus court est obtenu en suivant les croix
*/
typedef struct _point {
int x;
int y;
} point;
typedef struct _segment {
point extremite[2];
} segment;
typedef struct _sgmList {
segment *ptr;
int nbElements;
int count;
} sgmList;
typedef struct _groupX {
int x;
segment *s; /* segment relatif */
} groupX;
typedef struct _groupY {
int y;
segment *s; /* segment relatif */
} groupY;
typedef struct _matHorizX {
groupX gx[]; /* tableau des x */
int count;
int nbElements;
} matriceHorizontale;
typedef struct _matVertY {
groupY gy[];
int count;
int nbElements;
} matriceVerticale;
typedef struct _matrice {
matriceHorizontale h;
matriceVerticale v;
int* checked[];
} matrice;
typedef struct _archi {
matrice mat;
} archi; |
Partager