File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 817
817
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
818
818
[Listing [moving-sphere-bbox]: < kbd > [moving_sphere.h]</ kbd > Moving sphere with bounding box]
819
819
820
- < div class ='together '>
821
- Now we need a new `aabb` constructor that takes two boxes as input:
820
+ Now we need a new `aabb` constructor that takes two boxes as input.
821
+ First, we'll add a new interval constructor that takes two intervals as input:
822
+
823
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
824
+ class interval {
825
+ public:
826
+ ...
827
+
828
+ interval(const interval& a, const interval& b)
829
+ : min(fmin(a.min, b.min)), max(fmax(a.max, b.max)) {}
830
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
831
+ [Listing [interval-from-intervals]: < kbd > [interval.h]</ kbd >
832
+ Interval constructor from two intervals
833
+ ]
834
+
835
+
836
+ Now we can use this to construct an axis-aligned bounding box from two input boxes.
822
837
823
838
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
824
839
class aabb {
835
850
};
836
851
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
837
852
[Listing [aabb-from-two-aabb]: < kbd > [aabb.h]</ kbd > AABB constructor from two AABB inputs]
838
- </ div >
839
853
840
854
841
855
Creating Bounding Boxes of Lists of Objects
You can’t perform that action at this time.
0 commit comments