GteIntrLine2OrientedBox2.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 
12 
13 // The queries consider the box to be a solid.
14 //
15 // The test-intersection queries use the method of separating axes. The
16 // find-intersection queries use parametric clipping against the four edges of
17 // the box.
18 
19 namespace gte
20 {
21 
22 template <typename Real>
23 class TIQuery<Real, Line2<Real>, OrientedBox2<Real>>
24  :
25  public TIQuery<Real, Line2<Real>, AlignedBox2<Real>>
26 {
27 public:
28  struct Result
29  :
30  public TIQuery<Real, Line2<Real>, AlignedBox2<Real>>::Result
31  {
32  // No additional relevant information to compute.
33  };
34 
35  Result operator()(Line2<Real> const& line, OrientedBox2<Real> const& box);
36 };
37 
38 template <typename Real>
39 class FIQuery<Real, Line2<Real>, OrientedBox2<Real>>
40  :
41  public FIQuery<Real, Line2<Real>, AlignedBox2<Real>>
42 {
43 public:
44  struct Result
45  :
46  public FIQuery<Real, Line2<Real>, AlignedBox2<Real>>::Result
47  {
48  // No additional relevant information to compute.
49  };
50 
51  Result operator()(Line2<Real> const& line, OrientedBox2<Real> const& box);
52 };
53 
54 
55 template <typename Real>
58  Line2<Real> const& line, OrientedBox2<Real> const& box)
59 {
60  // Transform the line to the oriented-box coordinate system.
61  Vector2<Real> diff = line.origin - box.center;
62  Vector2<Real> lineOrigin
63  {
64  Dot(diff, box.axis[0]),
65  Dot(diff, box.axis[1])
66  };
67  Vector2<Real> lineDirection
68  {
69  Dot(line.direction, box.axis[0]),
70  Dot(line.direction, box.axis[1])
71  };
72 
73  Result result;
74  this->DoQuery(lineOrigin, lineDirection, box.extent, result);
75  return result;
76 }
77 
78 template <typename Real>
81  Line2<Real> const& line, OrientedBox2<Real> const& box)
82 {
83  // Transform the line to the oriented-box coordinate system.
84  Vector2<Real> diff = line.origin - box.center;
85  Vector2<Real> lineOrigin
86  {
87  Dot(diff, box.axis[0]),
88  Dot(diff, box.axis[1])
89  };
90  Vector2<Real> lineDirection
91  {
92  Dot(line.direction, box.axis[0]),
93  Dot(line.direction, box.axis[1])
94  };
95 
96  Result result;
97  this->DoQuery(lineOrigin, lineDirection, box.extent, result);
98  for (int i = 0; i < result.numIntersections; ++i)
99  {
100  result.point[i] = line.origin + result.parameter[i] * line.direction;
101  }
102  return result;
103 }
104 
105 
106 }
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
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