GteCylinder3.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/GteLine.h>
11 
12 // The cylinder axis is a line. The origin of the cylinder is chosen to be
13 // the line origin. The cylinder wall is at a distance R units from the axis.
14 // An infinite cylinder has infinite height. A finite cylinder has center C
15 // at the line origin and has a finite height H. The segment for the finite
16 // cylinder has endpoints C-(H/2)*D and C+(H/2)*D where D is a unit-length
17 // direction of the line.
18 
19 namespace gte
20 {
21 
22 template <typename Real>
23 class Cylinder3
24 {
25 public:
26  // Construction and destruction. The default constructor sets axis to
27  // (0,0,1), radius to 1, and height to 1.
28  Cylinder3();
29  Cylinder3(Line3<Real> const& inAxis, Real inRadius, Real inHeight);
30 
32  Real radius, height;
33 
34 public:
35  // Comparisons to support sorted containers.
36  bool operator==(Cylinder3 const& cylinder) const;
37  bool operator!=(Cylinder3 const& cylinder) const;
38  bool operator< (Cylinder3 const& cylinder) const;
39  bool operator<=(Cylinder3 const& cylinder) const;
40  bool operator> (Cylinder3 const& cylinder) const;
41  bool operator>=(Cylinder3 const& cylinder) const;
42 };
43 
44 
45 template <typename Real>
47  :
48  axis(Line3<Real>()),
49  radius((Real)1),
50  height((Real)1)
51 {
52 }
53 
54 template <typename Real>
55 Cylinder3<Real>::Cylinder3(Line3<Real> const& inAxis, Real inRadius,
56  Real inHeight)
57  :
58  axis(inAxis),
59  radius(inRadius),
60  height(inHeight)
61 {
62 }
63 
64 template <typename Real>
65 bool Cylinder3<Real>::operator==(Cylinder3 const& cylinder) const
66 {
67  return axis == cylinder.axis
68  && radius == cylinder.radius
69  && height == cylinder.height;
70 }
71 
72 template <typename Real>
73 bool Cylinder3<Real>::operator!=(Cylinder3 const& cylinder) const
74 {
75  return !operator==(cylinder);
76 }
77 
78 template <typename Real>
79 bool Cylinder3<Real>::operator<(Cylinder3 const& cylinder) const
80 {
81  if (axis < cylinder.axis)
82  {
83  return true;
84  }
85 
86  if (axis > cylinder.axis)
87  {
88  return false;
89  }
90 
91  if (radius < cylinder.radius)
92  {
93  return true;
94  }
95 
96  if (radius > cylinder.radius)
97  {
98  return false;
99  }
100 
101  return height < cylinder.height;
102 }
103 
104 template <typename Real>
105 bool Cylinder3<Real>::operator<=(Cylinder3 const& cylinder) const
106 {
107  return operator<(cylinder) || operator==(cylinder);
108 }
109 
110 template <typename Real>
111 bool Cylinder3<Real>::operator>(Cylinder3 const& cylinder) const
112 {
113  return !operator<=(cylinder);
114 }
115 
116 template <typename Real>
117 bool Cylinder3<Real>::operator>=(Cylinder3 const& cylinder) const
118 {
119  return !operator<(cylinder);
120 }
121 
122 
123 }
bool operator==(Cylinder3 const &cylinder) const
Definition: GteCylinder3.h:65
bool operator<=(Cylinder3 const &cylinder) const
Definition: GteCylinder3.h:105
bool operator>=(Cylinder3 const &cylinder) const
Definition: GteCylinder3.h:117
bool operator>(Cylinder3 const &cylinder) const
Definition: GteCylinder3.h:111
bool operator!=(Cylinder3 const &cylinder) const
Definition: GteCylinder3.h:73
GLint GLsizei GLsizei height
Definition: glcorearb.h:98
Line3< Real > axis
Definition: GteCylinder3.h:31
bool operator<(Cylinder3 const &cylinder) const
Definition: GteCylinder3.h:79


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