GteIntrSegment3OrientedBox3.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, Segment3<Real>, OrientedBox3<Real>>
24  :
25  public TIQuery<Real, Segment3<Real>, AlignedBox3<Real>>
26 {
27 public:
28  struct Result
29  :
30  public TIQuery<Real, Segment3<Real>, AlignedBox3<Real>>::Result
31  {
32  // No additional information to compute.
33  };
34 
35  Result operator()(Segment3<Real> const& segment,
36  OrientedBox3<Real> const& box);
37 };
38 
39 template <typename Real>
40 class FIQuery<Real, Segment3<Real>, OrientedBox3<Real>>
41  :
42  public FIQuery<Real, Segment3<Real>, AlignedBox3<Real>>
43 {
44 public:
45  struct Result
46  :
47  public FIQuery<Real, Segment3<Real>, AlignedBox3<Real>>::Result
48  {
49  // No additional relevant information to compute.
50  };
51 
52  Result operator()(Segment3<Real> const& segment,
53  OrientedBox3<Real> const& box);
54 };
55 
56 
57 template <typename Real>
60  Segment3<Real> const& segment, OrientedBox3<Real> const& box)
61 {
62  // Transform the segment to the oriented-box coordinate system.
63  Vector3<Real> tmpOrigin, tmpDirection;
64  Real segExtent;
65  segment.GetCenteredForm(tmpOrigin, tmpDirection, segExtent);
66  Vector3<Real> diff = tmpOrigin - box.center;
67  Vector3<Real> segOrigin
68  {
69  Dot(diff, box.axis[0]),
70  Dot(diff, box.axis[1]),
71  Dot(diff, box.axis[2])
72  };
73  Vector3<Real> segDirection
74  {
75  Dot(tmpDirection, box.axis[0]),
76  Dot(tmpDirection, box.axis[1]),
77  Dot(tmpDirection, box.axis[2])
78  };
79 
80  Result result;
81  this->DoQuery(segOrigin, segDirection, segExtent, box.extent, result);
82  return result;
83 }
84 
85 template <typename Real>
88  Segment3<Real> const& segment, OrientedBox3<Real> const& box)
89 {
90  // Transform the segment to the oriented-box coordinate system.
91  Vector3<Real> tmpOrigin, tmpDirection;
92  Real segExtent;
93  segment.GetCenteredForm(tmpOrigin, tmpDirection, segExtent);
94  Vector3<Real> diff = tmpOrigin - box.center;
95  Vector3<Real> segOrigin
96  {
97  Dot(diff, box.axis[0]),
98  Dot(diff, box.axis[1]),
99  Dot(diff, box.axis[2])
100  };
101  Vector3<Real> segDirection
102  {
103  Dot(tmpDirection, box.axis[0]),
104  Dot(tmpDirection, box.axis[1]),
105  Dot(tmpDirection, box.axis[2])
106  };
107 
108  Result result;
109  this->DoQuery(segOrigin, segDirection, segExtent, box.extent, result);
110  for (int i = 0; i < result.numPoints; ++i)
111  {
112  result.point[i] = segOrigin + result.lineParameter[i] * segDirection;
113  }
114  return result;
115 }
116 
117 
118 }
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