GteIntrLine2Arc2.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 
10 #include <Mathematics/GteArc2.h>
12 
13 // The queries consider the arc to be a 1-dimensional object.
14 
15 namespace gte
16 {
17 
18 template <typename Real>
19 class TIQuery<Real, Line2<Real>, Arc2<Real>>
20 {
21 public:
22  struct Result
23  {
24  bool intersect;
25  };
26 
27  Result operator()(Line2<Real> const& line, Arc2<Real> const& arc);
28 };
29 
30 template <typename Real>
31 class FIQuery<Real, Line2<Real>, Arc2<Real>>
32 {
33 public:
34  struct Result
35  {
36  bool intersect;
38  std::array<Real, 2> parameter;
39  std::array<Vector2<Real>, 2> point;
40  };
41 
42  Result operator()(Line2<Real> const& line, Arc2<Real> const& arc);
43 };
44 
45 
46 template <typename Real>
47 typename TIQuery<Real, Line2<Real>, Arc2<Real>>::Result
49  Line2<Real> const& line, Arc2<Real> const& arc)
50 {
51  Result result;
53  auto laResult = laQuery(line, arc);
54  result.intersect = laResult.intersect;
55  return result;
56 }
57 
58 template <typename Real>
59 typename FIQuery<Real, Line2<Real>, Arc2<Real>>::Result
61  Line2<Real> const& line, Arc2<Real> const& arc)
62 {
63  Result result;
64 
66  Circle2<Real> circle(arc.center, arc.radius);
67  auto lcResult = lcQuery(line, circle);
68  if (lcResult.intersect)
69  {
70  // Test whether line-circle intersections are on the arc.
71  result.numIntersections = 0;
72  for (int i = 0; i < lcResult.numIntersections; ++i)
73  {
74  if (arc.Contains(lcResult.point[i]))
75  {
76  result.intersect = true;
77  result.parameter[result.numIntersections]
78  = lcResult.parameter[i];
79  result.point[result.numIntersections++]
80  = lcResult.point[i];
81  }
82  }
83  }
84  else
85  {
86  result.intersect = false;
87  result.numIntersections = 0;
88  }
89 
90  return result;
91 }
92 
93 
94 }
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 04:00:00