-
Notifications
You must be signed in to change notification settings - Fork 0
/
Polygon.h
54 lines (39 loc) · 1.16 KB
/
Polygon.h
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
/*======================================================*\
Wednesday September the 25th 2013
Arash HABIBI
Polygon.h
\*======================================================*/
#ifndef _POLYGON_H_
#define _POLYGON_H_
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/glx.h>
#include "Vector.h"
#define P_MAX_VERTICES 1000
typedef struct
{
int _nb_vertices;
Vector _vertices[P_MAX_VERTICES];
int _is_closed;
int _is_filled;
int _is_convex;
} Polygon;
Polygon* P_new();
void P_copy(Polygon *original, Polygon *copy);
void P_addVertex(Polygon *P, Vector p);
void P_removeLastVertex(Polygon *P);
void P_print(Polygon *P, char *message);
void P_draw(Polygon *P, int width, int height);
int P_isConvex(Polygon *P);
int P_isOnTheLeftOfAllEdges(Polygon *P, Vector M);
int P_nbEdgesIntersectedByRay(Polygon *P, Vector M, Vector u_ray);
int P_isInside(Polygon *P, Vector M);
void P_turnAroundY(Polygon *P, double radians);
Vector P_center(Polygon *P);
Vector P_normal(Polygon *P);
void P_scale(Polygon *P, double factor);
void P_translate(Polygon *P, Vector trans);
void P_rotate(Polygon *P, Vector normal);
#endif // _POLYGON_H_