-
Notifications
You must be signed in to change notification settings - Fork 16
/
point.h
69 lines (52 loc) · 1.3 KB
/
point.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
/* point.h
* Karin Lagergren
*
* Cartesian points and vectors for signal calculation code
*
* November 2007, added dot product, vector subtraction, cross product
*/
#ifndef _POINT_H
#define _POINT_H
struct point{
float x;
float y;
float z;
};
typedef struct point point;
typedef struct point vector;
typedef struct{
int x;
int y;
int z;
}int_pt;
/* vector_norm
* returns the absolute value of vector v
* e is unit vector in v's direction
*/
float vector_norm(vector v, vector *e);
/* vector_length
* returns length of vector v
*/
float vector_length(vector v);
/* distance
* returns distance between points
*/
float distance(point pt1, point pt2);
/* vector_add */
vector vector_add(vector v1, vector v2);
/*vector subtraction, v1-v2*/
vector vector_sub(vector v1, vector v2);
/*vector dot product, v1*v1*/
float dot_prod(vector v1, vector v2);
/*vector cross product, v1 X v2*/
vector cross_prod(vector v1, vector v2);
/*scale vector by factor*/
vector vector_scale(vector v, float factor);
/*rotate vector by angle_deg degrees around z axis*/
vector vector_rotate_z(vector v, float angle_deg);
/* pt_to_str
* string representation of point pt
* written to string str, which has guaranteed length len
*/
char *pt_to_str(char *str, int len, point pt);
#endif /*#ifndef _POINT_H*/