-
Notifications
You must be signed in to change notification settings - Fork 0
/
triangle_and_vertex.h
74 lines (62 loc) · 2.64 KB
/
triangle_and_vertex.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __triangle_and_vertex__
#define __triangle_and_vertex__
#include <gmp.h>
/*****************************************************************************/
/* this is a (3d probably) rational vector */
/*****************************************************************************/
typedef struct {
mpq_t* coord;
int dim;
int malloced;
} rvector;
/*****************************************************************************/
/* this is a 3d triangle */
/*****************************************************************************/
typedef struct {
int* verts; //this is the vertex indices in the vertex list
//the number of vertices should be implicit
//rvector normal[3];
double area;
int is_scl_linear; //1 means yes, 0 means unknown, -1 means no
} triangle;
/*****************************************************************************/
/* this is a list of triangles */
/*****************************************************************************/
typedef struct {
triangle* tris;
int num_tris;
int first_nonlinear_triangle; //this records the index of the first triangle
//which isn't linear (which we can work on)
} tri_list;
/*****************************************************************************/
/* this is a list of vertices */
/*****************************************************************************/
typedef struct {
rvector* verts;
int num_verts;
} vert_list;
typedef struct {
double** verts;
int num_verts;
} vert_list_d;
void dvector_cross(double* dest, double* a, double* b);
double dvector_dot(double* a, double* b);
double triangle_area(vert_list* V, triangle* T);
void tri_list_add_copy(tri_list* T, triangle* t);
void tri_list_print(tri_list* T, vert_list* V);
void tri_list_print_d(tri_list* T, vert_list_d* V);
void tri_list_delete_index(tri_list* T, int index);
void tri_list_delete_indices(tri_list* T, int ind1, int ind2);
void tri_list_free(tri_list* T);
void rvector_init(rvector* v, int len) ;
void rvector_free(rvector* v);
void rvector_sub(rvector* dest, rvector* a, rvector* b);
void rvector_dot(mpq_t ans, rvector* v1, rvector* v2);
void rvector_print(rvector* v);
void rvector_cross(rvector* c, rvector* v1, rvector* v2);
void vert_list_add_copy(vert_list* V, rvector* v);
void vert_list_d_add_copy(vert_list_d* V, double* v);
void vert_list_d_delete_index(vert_list_d* V, int ind);
void vert_list_free(vert_list* V);
void vert_list_d_free(vert_list_d* V);
#endif