GteDistPointLine.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>
12 
13 namespace gte
14 {
15 
16 template <int N, typename Real>
17 class DCPQuery<Real, Vector<N, Real>, Line<N, Real>>
18 {
19 public:
20  struct Result
21  {
23  Real lineParameter; // t in (-infinity,+infinity)
24  Vector<N, Real> lineClosest; // origin + t * direction
25  };
26 
27  Result operator()(Vector<N, Real> const& point,
28  Line<N, Real> const& line);
29 };
30 
31 // Template aliases for convenience.
32 template <int N, typename Real>
33 using DCPPointLine =
35 
36 template <typename Real>
38 
39 template <typename Real>
41 
42 
43 template <int N, typename Real>
44 typename DCPQuery<Real, Vector<N, Real>, Line<N, Real>>::Result
45 DCPQuery<Real, Vector<N, Real>, Line<N, Real>>::operator()(
46  Vector<N, Real> const& point, Line<N, Real> const& line)
47 {
48  Result result;
49 
50  Vector<N, Real> diff = point - line.origin;
51  result.lineParameter = Dot(line.direction, diff);
52  result.lineClosest = line.origin + result.lineParameter*line.direction;
53 
54  diff = point - result.lineClosest;
55  result.sqrDistance = Dot(diff, diff);
56  result.distance = sqrt(result.sqrDistance);
57 
58  return result;
59 }
60 
61 
62 }
GLsizei GLsizei GLfloat distance
Definition: glext.h:9704
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