A repository of code for the book Computational Geometry in C, 2nd edition.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

64 lines
1.9 KiB

#include <stdio.h>
#include "vertex.h"
#include "math.h"
void chapter1() {
// Initialize our chapter 1 polygon
struct Vertex *v0 = new_vertex(0, 0, 0);
struct Vertex *v1 = new_vertex(1, 10, 7);
struct Vertex *v2 = new_vertex(2, 12, 3);
struct Vertex *v3 = new_vertex(3, 20, 8);
struct Vertex *v4 = new_vertex(4, 13, 17);
struct Vertex *v5 = new_vertex(5, 10, 12);
struct Vertex *v6 = new_vertex(6, 12, 14);
struct Vertex *v7 = new_vertex(7, 14, 9);
struct Vertex *v8 = new_vertex(8, 8, 10);
struct Vertex *v9 = new_vertex(9, 6, 14);
struct Vertex *v10 = new_vertex(10, 10, 15);
struct Vertex *v11 = new_vertex(11, 7, 18);
struct Vertex *v12 = new_vertex(12, 0, 16);
struct Vertex *v13 = new_vertex(13, 1, 13);
struct Vertex *v14 = new_vertex(14, 3, 15);
struct Vertex *v15 = new_vertex(15, 5, 8);
struct Vertex *v16 = new_vertex(16, -2, 9);
struct Vertex *v17 = new_vertex(17, 5, 5);
// TODO: You may be able to change this back to normal as long as you're
// using -> to set the value on the struct. This is interpreted
// as (*thing).xyz so you are doing too much work on pointers
// in this.
add_vertex(&v0, &v0, &v1);
add_vertex(&v0, &v1, &v2);
add_vertex(&v0, &v2, &v3);
add_vertex(&v0, &v3, &v4);
add_vertex(&v0, &v4, &v5);
add_vertex(&v0, &v5, &v6);
add_vertex(&v0, &v6, &v7);
add_vertex(&v0, &v7, &v8);
add_vertex(&v0, &v8, &v9);
add_vertex(&v0, &v9, &v10);
add_vertex(&v0, &v10, &v11);
add_vertex(&v0, &v11, &v12);
add_vertex(&v0, &v12, &v13);
add_vertex(&v0, &v13, &v14);
add_vertex(&v0, &v14, &v15);
add_vertex(&v0, &v15, &v16);
add_vertex(&v0, &v16, &v17);
init_ear(v0);
print_polygon(v0);
triangulate(v0);
//print_polygon(v0);
free_polygon(&v0);
}
int main()
{
chapter1();
return 0;
}