GteDistLine3OrientedBox3.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/GteLine.h>
13 
14 namespace gte
15 {
16 
17 template <typename Real>
18 class DCPQuery<Real, Line3<Real>, OrientedBox3<Real>>
19  :
20  public DCPQuery<Real, Line3<Real>, AlignedBox3<Real>>
21 {
22 public:
23  struct Result
24  :
25  public DCPQuery<Real, Line3<Real>, AlignedBox3<Real>>::Result
26  {
27  // No additional information to compute.
28  };
29 
30  Result operator()(Line3<Real> const& line, OrientedBox3<Real> const& box);
31 };
32 
33 
34 template <typename Real>
37  Line3<Real> const& line, OrientedBox3<Real> const& box)
38 {
39  // Transform the line to the coordinate system of the oriented box.
40  // In this system, the box is axis-aligned with center at the origin.
41  Vector3<Real> diff = line.origin - box.center;
42  Vector3<Real> point, direction;
43  for (int i = 0; i < 3; ++i)
44  {
45  point[i] = Dot(diff, box.axis[i]);
46  direction[i] = Dot(line.direction, box.axis[i]);
47  }
48 
49  Result result;
50  this->DoQuery(point, direction, box.extent, result);
51 
52  // Compute the closest point on the line.
53  result.closestPoint[0] =
54  line.origin + result.lineParameter*line.direction;
55 
56  // Compute the closest point on the box.
57  result.closestPoint[1] = box.center;
58  for (int i = 0; i < 3; ++i)
59  {
60  result.closestPoint[1] += point[i] * box.axis[i];
61  }
62  return result;
63 }
64 
65 
66 }
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
GLuint64EXT * result
Definition: glext.h:10003


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59