forked from lizboese/CU-CSCI3308-CIPractice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry.h
28 lines (22 loc) · 747 Bytes
/
geometry.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
/*
* geometry.h
* Andy Sayler
* CSCI 3308
* Summer 2014
*
* This file contains a simple geomtery functions.
*
*/
#include <stdbool.h>
/* 2D Coordinate Struct */
typedef struct coord_2d {
double x;
double y;
} coord_2d_t;
/* Return the distance between two 2D coordinates */
double coord_2d_dist(const coord_2d_t* a, const coord_2d_t* b);
/* Test if two 2D coordinates are equal (e.g. withen 0.01 of each other) */
bool coord_2d_eq(const coord_2d_t* a, const coord_2d_t* b);
/* Calculate the midpoint between two 2D coordinates and load into mid */
void coord_2d_midpoint(coord_2d_t* mid, const coord_2d_t* a, const coord_2d_t* b);
double coord_2d_area_triangle(const coord_2d_t* a, const coord_2d_t* b, const coord_2d_t* c);