Point Cloud Library (PCL)  1.9.1-dev
opennurbs_cylinder.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_CYLINDER_INC_)
18 #define OPENNURBS_CYLINDER_INC_
19 
20 class ON_NurbsSurface;
21 class ON_RevSurface;
22 class ON_Brep;
23 
24 /*
25 Description:
26  ON_Cylinder is a right circular cylinder.
27 */
28 class ON_CLASS ON_Cylinder
29 {
30 public:
31  ON_Cylinder(); // zeros all fields - cylinder is invalid
32 
33  ON_Cylinder( // infinte cylinder
34  const ON_Circle& // point on the bottom plane
35  );
36 
37  ON_Cylinder( // infinte cylinder
38  const ON_Circle&, // point on the bottom plane
39  double // height
40  );
41 
42  ~ON_Cylinder();
43 
44  bool Create(
45  const ON_Circle& // point on the bottom plane
46  );
47 
48  bool Create(
49  const ON_Circle&, // point on the bottom plane
50  double // height
51  );
52 
53  bool IsValid() const; // returns true if all fields contain reasonable
54  // information and equation jibes with point and Z.
55 
56  bool IsFinite() const; // returns true if the cylinder is finite
57  // (height[0] != height[1]) and false if the
58  // cylinder is infinite.
59 
60  const ON_3dVector& Axis() const;
61  const ON_3dPoint& Center() const;
62  double Height() const; // returns 0 for infinite cylinder
63  ON_Circle CircleAt(
64  double // linear parameter
65  ) const;
66  ON_Line LineAt(
67  double // angular parameter
68  ) const;
69 
70  // evaluate parameters and return point
71  ON_3dPoint PointAt(
72  double, // angular parameter [0,2pi]
73  double // linear parameter (height from base circle's plane)
74  ) const;
75  ON_3dPoint NormalAt(
76  double, // angular parameter [0,2pi]
77  double // linear parameter (height from base circle's plane)
78  ) const;
79 
80  // returns parameters of point on cylinder that is closest to given point
81  bool ClosestPointTo(
82  ON_3dPoint,
83  double*, // angular parameter [0,2pi]
84  double* // linear parameter (height from base circle's plane)
85  ) const;
86  // returns point on cylinder that is closest to given point
87  ON_3dPoint ClosestPointTo(
88  ON_3dPoint
89  ) const;
90 
91  // For intersections see ON_Intersect();
92 
93  // rotate cylinder about its origin
94  bool Rotate(
95  double, // sin(angle)
96  double, // cos(angle)
97  const ON_3dVector& // axis of rotation
98  );
99  bool Rotate(
100  double, // angle in radians
101  const ON_3dVector& // axis of rotation
102  );
103 
104  // rotate cylinder about a point and axis
105  bool Rotate(
106  double, // sin(angle)
107  double, // cos(angle)
108  const ON_3dVector&, // axis of rotation
109  const ON_3dPoint& // center of rotation
110  );
111  bool Rotate(
112  double, // angle in radians
113  const ON_3dVector&, // axis of rotation
114  const ON_3dPoint& // center of rotation
115  );
116 
117  bool Translate(
118  const ON_3dVector&
119  );
120 
121  // parameterization of NURBS surface does not match cylinder's transcendental paramaterization
122  int GetNurbForm( ON_NurbsSurface& ) const; // returns 0=failure, 2=success
123 
124  /*
125  Description:
126  Creates a surface of revolution definition of the cylinder.
127  Parameters:
128  srf - [in] if not NULL, then this srf is used.
129  Result:
130  A surface of revolution or NULL if the cylinder is not
131  valid or is infinite.
132  */
133  ON_RevSurface* RevSurfaceForm( ON_RevSurface* srf = NULL ) const;
134 
135 public: // members left public
136  // base circle
138 
139 
140  // If height[0] = height[1], the cylinder is infinite,
141  // Otherwise, height[0] < height[1] and the center of
142  // the "bottom" cap is
143  //
144  // circle.plane.origin + height[0]*circle.plane.zaxis,
145  //
146  // and the center of the top cap is
147  //
148  // circle.plane.origin + height[1]*circle.plane.zaxis.
149  double height[2];
150 };
151 
152 #endif