GteIntrAlignedBox2AlignedBox2.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
11 #include <Mathematics/GteFIQuery.h>
12 #include <Mathematics/GteTIQuery.h>
13 
14 // The queries consider the box to be a solid.
15 //
16 // The aligned-aligned queries use simple min-max comparisions. The
17 // interesection of aligned boxes is an aligned box, possibly degenerate,
18 // where min[d] == max[d] for at least one dimension d.
19 
20 namespace gte
21 {
22 
23 template <typename Real>
24 class TIQuery<Real, AlignedBox2<Real>, AlignedBox2<Real>>
25 {
26 public:
27  struct Result
28  {
29  bool intersect;
30  };
31 
32  Result operator()(AlignedBox2<Real> const& box0,
33  AlignedBox2<Real> const& box1);
34 };
35 
36 template <typename Real>
37 class FIQuery<Real, AlignedBox2<Real>, AlignedBox2<Real>>
38 {
39 public:
40  struct Result
41  {
42  bool intersect;
44  };
45 
46  Result operator()(AlignedBox2<Real> const& box0,
47  AlignedBox2<Real> const& box1);
48 };
49 
50 
51 template <typename Real>
54  AlignedBox2<Real> const& box0, AlignedBox2<Real> const& box1)
55 {
56  Result result;
57  for (int i = 0; i < 2; i++)
58  {
59  if (box0.max[i] < box1.min[i] || box0.min[i] > box1.max[i])
60  {
61  result.intersect = false;
62  return result;
63  }
64  }
65  result.intersect = true;
66  return result;
67 }
68 
69 template <typename Real>
72  AlignedBox2<Real> const& box0, AlignedBox2<Real> const& box1)
73 {
74  Result result;
75  for (int i = 0; i < 2; i++)
76  {
77  if (box0.max[i] < box1.min[i] || box0.min[i] > box1.max[i])
78  {
79  result.intersect = false;
80  return result;
81  }
82  }
83 
84  for (int i = 0; i < 2; i++)
85  {
86  if (box0.max[i] <= box1.max[i])
87  {
88  result.box.max[i] = box0.max[i];
89  }
90  else
91  {
92  result.box.max[i] = box1.max[i];
93  }
94 
95  if (box0.min[i] <= box1.min[i])
96  {
97  result.box.min[i] = box1.min[i];
98  }
99  else
100  {
101  result.box.min[i] = box0.min[i];
102  }
103  }
104  result.intersect = true;
105  return result;
106 }
107 
108 
109 }
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
GLuint64EXT * result
Definition: glext.h:10003


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00