00001 /* $NoKeywords: $ */ 00002 /* 00003 // 00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved. 00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert 00006 // McNeel & Associates. 00007 // 00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED. 00011 // 00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>. 00013 // 00015 */ 00016 00017 #if !defined(OPENNURBS_CYLINDER_INC_) 00018 #define OPENNURBS_CYLINDER_INC_ 00019 00020 class ON_NurbsSurface; 00021 class ON_RevSurface; 00022 class ON_Brep; 00023 00024 /* 00025 Description: 00026 ON_Cylinder is a right circular cylinder. 00027 */ 00028 class ON_CLASS ON_Cylinder 00029 { 00030 public: 00031 ON_Cylinder(); // zeros all fields - cylinder is invalid 00032 00033 ON_Cylinder( // infinte cylinder 00034 const ON_Circle& // point on the bottom plane 00035 ); 00036 00037 ON_Cylinder( // infinte cylinder 00038 const ON_Circle&, // point on the bottom plane 00039 double // height 00040 ); 00041 00042 ~ON_Cylinder(); 00043 00044 bool Create( 00045 const ON_Circle& // point on the bottom plane 00046 ); 00047 00048 bool Create( 00049 const ON_Circle&, // point on the bottom plane 00050 double // height 00051 ); 00052 00053 bool IsValid() const; // returns true if all fields contain reasonable 00054 // information and equation jibes with point and Z. 00055 00056 bool IsFinite() const; // returns true if the cylinder is finite 00057 // (height[0] != height[1]) and false if the 00058 // cylinder is infinite. 00059 00060 const ON_3dVector& Axis() const; 00061 const ON_3dPoint& Center() const; 00062 double Height() const; // returns 0 for infinite cylinder 00063 ON_Circle CircleAt( 00064 double // linear parameter 00065 ) const; 00066 ON_Line LineAt( 00067 double // angular parameter 00068 ) const; 00069 00070 // evaluate parameters and return point 00071 ON_3dPoint PointAt( 00072 double, // angular parameter [0,2pi] 00073 double // linear parameter (height from base circle's plane) 00074 ) const; 00075 ON_3dPoint NormalAt( 00076 double, // angular parameter [0,2pi] 00077 double // linear parameter (height from base circle's plane) 00078 ) const; 00079 00080 // returns parameters of point on cylinder that is closest to given point 00081 bool ClosestPointTo( 00082 ON_3dPoint, 00083 double*, // angular parameter [0,2pi] 00084 double* // linear parameter (height from base circle's plane) 00085 ) const; 00086 // returns point on cylinder that is closest to given point 00087 ON_3dPoint ClosestPointTo( 00088 ON_3dPoint 00089 ) const; 00090 00091 // For intersections see ON_Intersect(); 00092 00093 // rotate cylinder about its origin 00094 bool Rotate( 00095 double, // sin(angle) 00096 double, // cos(angle) 00097 const ON_3dVector& // axis of rotation 00098 ); 00099 bool Rotate( 00100 double, // angle in radians 00101 const ON_3dVector& // axis of rotation 00102 ); 00103 00104 // rotate cylinder about a point and axis 00105 bool Rotate( 00106 double, // sin(angle) 00107 double, // cos(angle) 00108 const ON_3dVector&, // axis of rotation 00109 const ON_3dPoint& // center of rotation 00110 ); 00111 bool Rotate( 00112 double, // angle in radians 00113 const ON_3dVector&, // axis of rotation 00114 const ON_3dPoint& // center of rotation 00115 ); 00116 00117 bool Translate( 00118 const ON_3dVector& 00119 ); 00120 00121 // parameterization of NURBS surface does not match cylinder's transcendental paramaterization 00122 int GetNurbForm( ON_NurbsSurface& ) const; // returns 0=failure, 2=success 00123 00124 /* 00125 Description: 00126 Creates a surface of revolution definition of the cylinder. 00127 Parameters: 00128 srf - [in] if not NULL, then this srf is used. 00129 Result: 00130 A surface of revolution or NULL if the cylinder is not 00131 valid or is infinite. 00132 */ 00133 ON_RevSurface* RevSurfaceForm( ON_RevSurface* srf = NULL ) const; 00134 00135 public: // members left public 00136 // base circle 00137 ON_Circle circle; 00138 00139 00140 // If height[0] = height[1], the cylinder is infinite, 00141 // Otherwise, height[0] < height[1] and the center of 00142 // the "bottom" cap is 00143 // 00144 // circle.plane.origin + height[0]*circle.plane.zaxis, 00145 // 00146 // and the center of the top cap is 00147 // 00148 // circle.plane.origin + height[1]*circle.plane.zaxis. 00149 double height[2]; 00150 }; 00151 00152 #endif