X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Frasterize;a=blobdiff_plain;f=aabb.h;fp=aabb.h;h=c0fa3783bbf84925202e89ff481c5299d8529127;hp=0000000000000000000000000000000000000000;hb=c875478cdd823c7df8fdc859941bd9e5948c9315;hpb=82087d9bb9e28c2375008bde4453f6c019419697 diff --git a/aabb.h b/aabb.h new file mode 100644 index 0000000..c0fa378 --- /dev/null +++ b/aabb.h @@ -0,0 +1,51 @@ + +/* + * CS5600 University of Utah + * Charles McGarvey + * mcgarvey@eng.utah.edu + */ + +#ifndef _AABB_H_ +#define _AABB_H_ + +#include "vec.h" + + +/* + * An axis-aligned bounding box. + */ +struct aabb +{ + vec_t min; + vec_t max; +}; +typedef struct aabb aabb_t; + +/* + * Initialize a axis-aligned bounding box. + */ +INLINE_MAYBE +void aabb_init(aabb_t* b, vec_t min, vec_t max) +{ + b->min = min; + b->max = max; +} + + +/* + * Create a new axis-aligned bounding box. + */ +INLINE_MAYBE +aabb_t aabb_new(vec_t min, vec_t max) +{ + aabb_t b; + aabb_init(&b, min, max); + return b; +} + +#define AABB_UNIT aabb_new(vec_new(S(-0.5), S(-0.5), S(-0.5)), \ + vec_new(S( 0.5), S( 0.5), S( 0.5))) + + +#endif // _AABB_H_ +