TinyRaytracer 0.1
A simple C++ raytracer
Loading...
Searching...
No Matches
interval.hpp
Go to the documentation of this file.
1
11#ifndef BVH_H
12#define BVH_H
13
14#include "vec3.hpp"
15#include <cmath>
16#include <algorithm>
17#include <memory>
18#include <vector>
19using std::shared_ptr;
20
21class Interval {
22public:
23 double min,max;
24
25 Interval() : min(+INFINITY),max(-INFINITY) {}
26
27 Interval(double min,double max):
28 min(min),max(max) {}
29
30 double size() const {return max - min;}
31
38 bool contains(double x) const {return min <= x && x <= max;}
39
46 bool surrounds(double x) const {return min <= x && x <= max;}
47
55 Interval expand(double delta) const {
56 return Interval(min - delta,max + delta);
57 }
58};
59
60#endif
Definition: interval.hpp:21
bool contains(double x) const
Returns if the value is within, border value returns true.
Definition: interval.hpp:38
bool surrounds(double x) const
Returns if the value is within, border value returns false.
Definition: interval.hpp:46
Interval expand(double delta) const
Expand the interval by delta on both ends.
Definition: interval.hpp:55