viewing source for "vector.h"

last commit

commit 2fcfc3b2e8e18bd4ab667b82d939cc2ba9b6a5d3 Author: Andrew Rader <andrew.r.rader@gmail.com> Date: Sun Jan 13 09:25:46 2008 -0800
Initial Commit

source code

01: #ifndef __VECTOR__H__
02: #define __VECTOR__H__
03: 
04: typedef struct {
05:     float x;
06:     float y;
07:     float z;
08: } vector;
09: 
10: typedef struct {
11:     vector *origin;
12:     vector *dir;
13: } ray;
14: 
15: typedef vector color;
16: 
17: /*
18:  * vect_add - computes a = a + b
19:  */
20: void vect_add( vector *a, vector *b );
21: 
22: /*
23:  * vect_addf - computes a = a + f
24:  */
25: void vect_addf( vector *a, float f );
26: 
27: /*
28:  * vect_sub - computes a = a - b
29:  */
30: void vect_sub( vector *a, vector *b );
31: 
32: /*
33:  * vect_subf - computes a = a - f
34:  */
35: void vect_subf( vector *a, float f );
36: 
37: /*
38:  * vect_mult - computes a = a * b
39:  */
40: void vect_mult( vector *a, vector *b );
41: 
42: /*
43:  * vect_multf -computes a = a * f
44:  */
45: void vect_multf( vector *a, float f );
46: 
47: /*
48:  * vect_length - returns the length of the vector
49:  */
50: float vect_length( vector *v );
51: 
52: /*
53:  * vect_normalize - normalizes a vector
54:  */
55: void vect_normalize( vector *v );
56: 
57: /*
58:  * vect_dot - computes the dot product of a and b
59:  */
60: float vect_dot( vector *a, vector *b );
61: 
62: /*
63:  * vect_copy - copies the values from one vector
64:  * to another
65:  */
66: inline void vect_copy( vector *dest, vector *src );
67: 
68: #endif