-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbounding_box.h
37 lines (31 loc) · 851 Bytes
/
bounding_box.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
#ifndef __BOUNDING_BOX_H__
#define __BOUNDING_BOX_H__
//#####################################################################
// Function #in
//#####################################################################
#include "object.h"
#include "ray.h"
#include "vec.h"
template<class T, int d>
vec<T,d> componentwise_max(const vec<T,d>& a, const vec<T,d>& b)
{
vec<T,d> r;
for(int i=0; i<d; i++) r[i] = std::max(a[i], b[i]);
return r;
}
template<class T, int d>
vec<T,d> componentwise_min(const vec<T,d>& a, const vec<T,d>& b)
{
vec<T,d> r;
for(int i=0; i<d; i++) r[i] = std::min(a[i], b[i]);
return r;
}
class Bounding_Box
{
public:
// lowermost and uppermost corners of bounding box
vec3 lo,hi;
bool Intersection(const Ray& ray, double& dist);
Bounding_Box Union(const Bounding_Box& bb) const;
};
#endif