opennurbs_circle.h
Go to the documentation of this file.
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(ON_CIRCLE_INC_)
00018 #define ON_CIRCLE_INC_
00019 
00020 class ON_NurbsCurve;
00021 
00022 /*
00023 Description:
00024         ON_Circle is a circle in 3d.  The cirle is represented by a radius and an 
00025         orthonormal frame       of the plane containing the circle, with origin at the center.
00026 
00027         An Is_Valid() circle has positive radius and an Is_ Valid() plane defining the frame.
00028         
00029         The circle is parameterized by radians from 0 to 2 Pi given by 
00030      t -> center + cos(t)*radius*xaxis + sin(t)*radius*yaxis    
00031         where center, xaxis and yaxis define the orthonormal frame of the circle's plane.  
00032 */
00033 class ON_CLASS ON_Circle
00034 {
00035 public:
00036   // Creates a radius one circle with center (0,0,0)
00037   // in the world XY plane
00038   ON_Circle();
00039 
00040   // Creates a circle in the plane with center at
00041   // plane.origin.
00042   ON_Circle(
00043     const ON_Plane& plane,
00044     double radius
00045     );
00046 
00047   // Creates a circle parallel to the world XY plane
00048   // with given center and radius
00049   ON_Circle(
00050     const ON_3dPoint& center,
00051     double radius
00052     );
00053 
00054   // Creates a circle parallel to the plane
00055   // with given center and radius.
00056   ON_Circle(
00057     const ON_Plane& plane,
00058     const ON_3dPoint& center,
00059     double radius
00060     );
00061 
00062   // Create a circle through three 2d points.
00063   // The start/end of the circle is at point P.
00064   ON_Circle( // circle through 3 2d points
00065     const ON_2dPoint& P,
00066     const ON_2dPoint& Q,
00067     const ON_2dPoint& R
00068     );
00069 
00070   // Create a circle through three 3d points.
00071   // The start/end of the circle is at point P.
00072   ON_Circle(
00073     const ON_3dPoint& P,
00074     const ON_3dPoint& Q,
00075     const ON_3dPoint& R
00076     );
00077 
00078   ~ON_Circle();
00079 
00080   // Creates a circle in the plane with center at
00081   // plane.origin.
00082   bool Create(
00083     const ON_Plane& plane,
00084     double radius
00085     );
00086 
00087   // Creates a circle parallel to the world XY plane
00088   // with given center and radius
00089   bool Create(
00090     const ON_3dPoint& center,
00091     double radius
00092     );
00093 
00094   // Creates a circle parallel to the plane
00095   // with given centr and radius.
00096   bool Create(
00097     const ON_Plane& plane,
00098     const ON_3dPoint& center,
00099     double radius
00100     );
00101 
00102   // Create a circle through three 2d points.
00103   // The start/end of the circle is at point P.
00104   bool Create( // circle through 3 2d points
00105     const ON_2dPoint& P,
00106     const ON_2dPoint& Q,
00107     const ON_2dPoint& R
00108     );
00109 
00110   // Create a circle through three 3d points.
00111   // The start/end of the circle is at point P.
00112   bool Create(
00113     const ON_3dPoint& P,
00114     const ON_3dPoint& Q,
00115     const ON_3dPoint& R
00116     );
00117 
00118   // Create a circle from two 2d points and a 
00119   // tangent at the first point.
00120   // The start/end of the circle is at point P.
00121   bool Create(
00122     const ON_2dPoint& P,
00123     const ON_2dVector& tangent_at_P,
00124     const ON_2dPoint& Q
00125     );
00126 
00127   // Create a circle from two 3d points and a 
00128   // tangent at the first point.
00129   // The start/end of the circle is at point P.
00130   bool Create(
00131     const ON_3dPoint& P,
00132     const ON_3dVector& tangent_at_P,
00133     const ON_3dPoint& Q
00134     );
00135 
00136         //      A Valid circle has m_radius>0 and m_plane.IsValid().
00137   bool IsValid() const;
00138 
00139   //bool UpdatePoints();  // sets m_point[] to have valid points
00140 
00141   bool IsInPlane( const ON_Plane&, double = ON_ZERO_TOLERANCE ) const;
00142 
00143   double Radius() const;
00144   double Diameter() const;
00145   double Circumference() const;
00146   const ON_3dPoint& Center() const;
00147   const ON_3dVector& Normal() const;
00148   const ON_Plane& Plane() const; // plane containing circle
00149 
00150   ON_BoundingBox BoundingBox() const;
00151 
00152   /*
00153         Description:
00154     Get tight bounding box.
00155         Parameters:
00156                 tight_bbox - [in/out] tight bounding box
00157                 bGrowBox -[in]  (default=false)                 
00158       If true and the input tight_bbox is valid, then returned
00159       tight_bbox is the union of the input tight_bbox and the 
00160       arc's tight bounding box.
00161                 xform -[in] (default=NULL)
00162       If not NULL, the tight bounding box of the transformed
00163       arc is calculated.  The arc is not modified.
00164         Returns:
00165     True if a valid tight_bbox is returned.
00166   */
00167         bool GetTightBoundingBox( 
00168                         ON_BoundingBox& tight_bbox, 
00169       int bGrowBox = false,
00170                         const ON_Xform* xform = 0
00171       ) const;
00172 
00173   bool Transform( const ON_Xform& );
00174 
00175   // Circles use trigonometric parameterization
00176   // t -> center + cos(t)*radius*xaxis + sin(t)*radius*yaxis
00177   ON_3dPoint PointAt( 
00178     double // evaluation parameter
00179     ) const;
00180   ON_3dVector DerivativeAt( 
00181     int,   // derivative (>=0)
00182     double // evaluation parameter
00183     ) const;
00184 
00185   ON_3dVector TangentAt(double) const;
00186 
00187   // returns parameters of point on circle that is closest to given point
00188   bool ClosestPointTo( 
00189          const ON_3dPoint& point, 
00190          double* t
00191          ) const;
00192 
00193   // returns point on circle that is closest to given point
00194   ON_3dPoint ClosestPointTo( 
00195          const ON_3dPoint& point
00196          ) const;
00197 
00198   // evaluate circle's implicit equation in plane
00199   double EquationAt( const ON_2dPoint& plane_point ) const;
00200 
00201   ON_2dVector GradientAt( const ON_2dPoint& plane_point ) const;
00202 
00203   // rotate circle about its center
00204   bool Rotate(
00205         double sin_angle,
00206         double cos_angle,
00207         const ON_3dVector& axis_of_rotation
00208         );
00209 
00210   bool Rotate(
00211         double angle_in_radians,
00212         const ON_3dVector&  axis_of_rotation
00213         );
00214 
00215   // rotate circle about a point and axis
00216   bool Rotate(
00217         double sin_angle,
00218         double cos_angle,
00219         const ON_3dVector& axis_of_rotation,
00220         const ON_3dPoint& center_of_rotation
00221         );
00222 
00223   bool Rotate(
00224         double angle_in_radians,
00225         const ON_3dVector&  axis_of_rotation,
00226         const ON_3dPoint& center_of_rotation
00227         );
00228 
00229   bool Translate(
00230         const ON_3dVector& delta
00231         );
00232 
00233   bool Reverse();
00234 
00235   // Description:
00236   //   Get a four span rational degree 2 NURBS circle representation
00237   //   of the circle.
00238   // Returns:
00239   //   2 for success, 0 for failure
00240   // Remarks:
00241   //   Note that the parameterization of NURBS curve
00242   //   does not match  circle's transcendental paramaterization.  
00243   //   Use ON_Circle::GetRadianFromNurbFormParameter() and
00244   //   ON_Circle::GetParameterFromRadian() to convert between 
00245   //   the NURBS curve parameter and the transcendental parameter.
00246   int GetNurbForm(
00247         ON_NurbsCurve& nurbs_curve
00248         ) const; 
00249 
00250   /*
00251   Description:
00252     Convert a NURBS curve circle parameter to a circle radians parameter.
00253   Parameters:
00254     nurbs_parameter - [in]
00255     circle_radians_parameter - [out]
00256   Example:
00257 
00258           ON_Circle circle = ...;
00259           double nurbs_t = 1.2345; // some number in interval (0,2.0*ON_PI).
00260           double circle_t;
00261           circle.GetRadianFromNurbFormParameter( nurbs_t, &circle_t );
00262 
00263           ON_NurbsCurve nurbs_curve;
00264           circle.GetNurbsForm( nurbs_curve );
00265           circle_pt = circle.PointAt(circle_t);
00266           nurbs_pt = nurbs_curve.PointAt(nurbs_t);
00267           // circle_pt and nurbs_pt will be the same
00268 
00269   Remarks:
00270     The NURBS curve parameter is with respect to the NURBS curve
00271     created by ON_Circle::GetNurbForm.  At nurbs parameter values of 
00272     0.0, 0.5*ON_PI, ON_PI, 1.5*ON_PI, and 2.0*ON_PI, the nurbs
00273     parameter and radian parameter are the same.  At all other
00274     values the nurbs and radian parameter values are different.
00275   See Also:
00276     ON_Circle::GetNurbFormParameterFromRadian
00277   */
00278   bool GetRadianFromNurbFormParameter(
00279         double nurbs_parameter,
00280         double* circle_radians_parameter
00281         ) const;
00282 
00283   /*
00284   Description:
00285     Convert a circle radians parameter to a NURBS curve circle parameter.
00286   Parameters:
00287     circle_radians_parameter - [in] 0.0 to 2.0*ON_PI
00288     nurbs_parameter - [out]
00289   Example:
00290 
00291           ON_Circle circle = ...;
00292           double circle_t = 1.2345; // some number in interval (0,2.0*ON_PI).
00293           double nurbs_t;
00294           circle.GetNurbFormParameterFromRadian( circle_t, &nurbs_t );
00295 
00296           ON_NurbsCurve nurbs_curve;
00297           circle.GetNurbsForm( nurbs_curve );
00298           circle_pt = circle.PointAt(circle_t);
00299           nurbs_pt = nurbs_curve.PointAt(nurbs_t);
00300           // circle_pt and nurbs_pt will be the same
00301 
00302   Remarks:
00303     The NURBS curve parameter is with respect to the NURBS curve
00304     created by ON_Circle::GetNurbForm.  At radian values of 
00305     0.0, 0.5*ON_PI, ON_PI, 1.5*ON_PI, and 2.0*ON_PI, the nurbs
00306     parameter and radian parameter are the same.  At all other
00307     values the nurbs and radian parameter values are different.
00308   See Also:
00309     ON_Circle::GetNurbFormParameterFromRadian
00310   */
00311   bool GetNurbFormParameterFromRadian(
00312         double circle_radians_parameter,
00313         double* nurbs_parameter
00314         ) const;
00315 
00316 public:
00317   // circle is in the plane with center at plane.m_origin.
00318   ON_Plane   plane;  
00319   double     radius;   // radius
00320   //ON_3dPoint m_point[3]; // 3 points on the circle
00321 };
00322 
00323 
00324 #endif
00325 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:00