#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include "util/box.h"
#include "util/vec3f.h"

int does_contain(const Box a, const Box b){
	return  (a.lower.x <= b.lower.x) && (b.upper.x <= a.upper.x)
				&&(a.lower.y <= b.lower.y) && (b.upper.y <= a.upper.y)
				&&(a.lower.z <= b.lower.z) && (b.upper.z <= a.upper.z);
}

Box box_intersection(const Box a, const Box b){
	return (Box){
		(Vec3f){fmax(a.lower.x,b.lower.x),fmax(a.lower.y,b.lower.y),fmax(a.lower.z,b.lower.z)},
		(Vec3f){fmin(a.upper.x,b.upper.x),fmax(a.upper.y,b.upper.y),fmax(a.upper.z,b.upper.z)}
	};
}

int is_valid_box(const Box a){
	return  (a.lower.x < a.upper.x) && (a.lower.y < a.upper.y) && (a.lower.z < a.upper.z); 
}

//for debug
void print_box(const Box a)
{
	printf("Box: (%f,%f,%f) -> (%f,%f,%f)\n",a.lower.x,a.lower.y,a.lower.z,a.upper.x,a.upper.y,a.upper.z);
}

