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