GteIntrLine3OrientedBox3.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 six faces of
17 // the box.
18 
19 namespace gte
20 {
21 
22 template <typename Real>
23 class TIQuery<Real, Line3<Real>, OrientedBox3<Real>>
24  :
25  public TIQuery<Real, Line3<Real>, AlignedBox3<Real>>
26 {
27 public:
28  struct Result
29  :
30  public TIQuery<Real, Line3<Real>, AlignedBox3<Real>>::Result
31  {
32  // No additional relevant information to compute.
33  };
34 
35  Result operator()(Line3<Real> const& line, OrientedBox3<Real> const& box);
36 };
37 
38 template <typename Real>
39 class FIQuery<Real, Line3<Real>, OrientedBox3<Real>>
40  :
41  public FIQuery<Real, Line3<Real>, AlignedBox3<Real>>
42 {
43 public:
44  struct Result
45  :
46  public FIQuery<Real, Line3<Real>, AlignedBox3<Real>>::Result
47  {
48  // No additional relevant information to compute.
49  };
50 
51  Result operator()(Line3<Real> const& line, OrientedBox3<Real> const& box);
52 };
53 
54 
55 template <typename Real>
58  Line3<Real> const& line, OrientedBox3<Real> const& box)
59 {
60  // Transform the line to the oriented-box coordinate system.
61  Vector3<Real> diff = line.origin - box.center;
62  Vector3<Real> lineOrigin
63  {
64  Dot(diff, box.axis[0]),
65  Dot(diff, box.axis[1]),
66  Dot(diff, box.axis[2])
67  };
68  Vector3<Real> lineDirection
69  {
70  Dot(line.direction, box.axis[0]),
71  Dot(line.direction, box.axis[1]),
72  Dot(line.direction, box.axis[2])
73  };
74 
75  Result result;
76  this->DoQuery(lineOrigin, lineDirection, box.extent, result);
77  return result;
78 }
79 
80 template <typename Real>
83  Line3<Real> const& line, OrientedBox3<Real> const& box)
84 {
85  // Transform the line to the oriented-box coordinate system.
86  Vector3<Real> diff = line.origin - box.center;
87  Vector3<Real> lineOrigin
88  {
89  Dot(diff, box.axis[0]),
90  Dot(diff, box.axis[1]),
91  Dot(diff, box.axis[2])
92  };
93  Vector3<Real> lineDirection
94  {
95  Dot(line.direction, box.axis[0]),
96  Dot(line.direction, box.axis[1]),
97  Dot(line.direction, box.axis[2])
98  };
99 
100  Result result;
101  this->DoQuery(lineOrigin, lineDirection, box.extent, result);
102  for (int i = 0; i < result.numPoints; ++i)
103  {
104  result.point[i] =
105  line.origin + result.lineParameter[i] * line.direction;
106  }
107  return result;
108 }
109 
110 
111 }
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