GteDistRay3AlignedBox3.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/GteRay.h>
12 
13 namespace gte
14 {
15 
16 template <typename Real>
17 class DCPQuery<Real, Ray3<Real>, AlignedBox3<Real>>
18 {
19 public:
20  struct Result
21  {
24  Vector3<Real> closestPoint[2];
25  };
26 
27  Result operator()(Ray3<Real> const& ray, AlignedBox3<Real> const& box);
28 };
29 
30 
31 template <typename Real>
34  Ray3<Real> const& ray, AlignedBox3<Real> const& box)
35 {
36  Result result;
37 
38  Line3<Real> line(ray.origin, ray.direction);
40  auto lbResult = lbQuery(line, box);
41 
42  if (lbResult.lineParameter >= (Real)0)
43  {
44  result.sqrDistance = lbResult.sqrDistance;
45  result.distance = lbResult.distance;
46  result.rayParameter = lbResult.lineParameter;
47  result.closestPoint[0] = lbResult.closestPoint[0];
48  result.closestPoint[1] = lbResult.closestPoint[1];
49  }
50  else
51  {
53  auto pbResult = pbQuery(ray.origin, box);
54  result.sqrDistance = pbResult.sqrDistance;
55  result.distance = pbResult.distance;
56  result.rayParameter = (Real)0;
57  result.closestPoint[0] = ray.origin;
58  result.closestPoint[1] = pbResult.boxClosest;
59  }
60  return result;
61 }
62 
63 
64 }
GLsizei GLsizei GLfloat distance
Definition: glext.h:9704
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 03:59:59