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