GteDistPointOrientedBox.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 namespace gte
14 {
15 
16 template <int N, typename Real>
17 class DCPQuery<Real, Vector<N, Real>, OrientedBox<N, Real>>
18  :
19  public DCPQuery<Real, Vector<N, Real>, AlignedBox<N, Real>>
20 {
21 public:
22  struct Result
23  :
24  public DCPQuery<Real, Vector<N, Real>, AlignedBox<N, Real>>::Result
25  {
26  // No additional information to compute.
27  };
28 
29  Result operator()(Vector<N, Real> const& point,
30  OrientedBox<N, Real> const& box);
31 };
32 
33 // Template aliases for convenience.
34 template <int N, typename Real>
35 using DCPPointOrientedBox =
37 
38 template <typename Real>
40 
41 template <typename Real>
43 
44 
45 template <int N, typename Real>
47 DCPQuery<Real, Vector<N, Real>, OrientedBox<N, Real>>::operator()(
48  Vector<N, Real> const& point, OrientedBox<N, Real> const& box)
49 {
50  // Translate the point to the coordinate system of the box. In this
51  // system, the box is axis-aligned with center at the origin.
52  Vector<N, Real> diff = point - box.center;
53  Vector<N, Real> closest;
54  for (int i = 0; i < N; ++i)
55  {
56  closest[i] = Dot(diff, box.axis[i]);
57  }
58 
59  Result result;
60  this->DoQuery(closest, box.extent, result);
61 
62  // Compute the closest point on the box.
63  result.boxClosest = box.center;
64  for (int i = 0; i < N; ++i)
65  {
66  result.boxClosest += closest[i] * box.axis[i];
67  }
68  return result;
69 }
70 
71 
72 }
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