GteCircle3.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/GteVector3.h>
11 
12 // The circle is the intersection of the sphere |X-C|^2 = r^2 and the
13 // plane Dot(N,X-C) = 0, where C is the circle center, r is the radius,
14 // and N is a unit-length plane normal.
15 
16 namespace gte
17 {
18 
19 template <typename Real>
20 class Circle3
21 {
22 public:
23 
24  // Construction and destruction. The default constructor sets center to
25  // (0,0,0), normal to (0,0,1), and radius to 1.
26  Circle3();
27  Circle3(Vector3<Real> const& inCenter, Vector3<Real> const& inNormal,
28  Real inRadius);
29 
30  // Public member access.
32  Real radius;
33 
34 public:
35  // Comparisons to support sorted containers.
36  bool operator==(Circle3 const& circle) const;
37  bool operator!=(Circle3 const& circle) const;
38  bool operator< (Circle3 const& circle) const;
39  bool operator<=(Circle3 const& circle) const;
40  bool operator> (Circle3 const& circle) const;
41  bool operator>=(Circle3 const& circle) const;
42 };
43 
44 
45 template <typename Real>
47  :
48  center(Vector3<Real>::Zero()),
49  normal(Vector3<Real>::Unit(2)),
50  radius((Real)1)
51 {
52 }
53 
54 template <typename Real>
56  Vector3<Real> const& inNormal, Real inRadius)
57  :
58  center(inCenter),
59  normal(inNormal),
60  radius(inRadius)
61 {
62 }
63 
64 template <typename Real>
65 bool Circle3<Real>::operator==(Circle3 const& circle) const
66 {
67  return center == circle.center
68  && normal == circle.normal
69  && radius == circle.radius;
70 }
71 
72 template <typename Real>
73 bool Circle3<Real>::operator!=(Circle3 const& circle) const
74 {
75  return !operator==(circle);
76 }
77 
78 template <typename Real>
79 bool Circle3<Real>::operator<(Circle3 const& circle) const
80 {
81  if (center < circle.center)
82  {
83  return true;
84  }
85 
86  if (center > circle.center)
87  {
88  return false;
89  }
90 
91  if (normal < circle.normal)
92  {
93  return true;
94  }
95 
96  if (normal > circle.normal)
97  {
98  return false;
99  }
100 
101  return radius < circle.radius;
102 }
103 
104 template <typename Real>
105 bool Circle3<Real>::operator<=(Circle3 const& circle) const
106 {
107  return operator<(circle) || operator==(circle);
108 }
109 
110 template <typename Real>
111 bool Circle3<Real>::operator>(Circle3 const& circle) const
112 {
113  return !operator<=(circle);
114 }
115 
116 template <typename Real>
117 bool Circle3<Real>::operator>=(Circle3 const& circle) const
118 {
119  return !operator<(circle);
120 }
121 
122 
123 }
bool operator<(Circle3 const &circle) const
Definition: GteCircle3.h:79
bool operator>(Circle3 const &circle) const
Definition: GteCircle3.h:111
Vector3< Real > normal
Definition: GteCircle3.h:31
bool operator<=(Circle3 const &circle) const
Definition: GteCircle3.h:105
bool operator!=(Circle3 const &circle) const
Definition: GteCircle3.h:73
bool operator==(Circle3 const &circle) const
Definition: GteCircle3.h:65
Vector3< Real > center
Definition: GteCircle3.h:31
bool operator>=(Circle3 const &circle) const
Definition: GteCircle3.h:117


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59