opennurbs_line.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_LINE_INC_)
00018 #define ON_LINE_INC_
00019 
00020 class ON_CLASS ON_Line
00021 {
00022 public:
00023 
00024   ON_Line();
00025   ON_Line( const ON_3dPoint& start, const ON_3dPoint& end );
00026   ~ON_Line();
00027 
00028   /*
00029   Returns:
00030     True if from != to.
00031   */
00032   bool IsValid() const;
00033 
00034   // line[0] = start point line[1] = end point
00035   ON_3dPoint& operator[](int);
00036   const ON_3dPoint& operator[](int) const;
00037 
00038 
00039   // Description:
00040   //   Create a line from two points.
00041   // Parameters:
00042   //   start - [in] point at start of line segment
00043   //   end - [in] point at end of line segment
00044   // Returns:
00045   //   true if start and end are distinct points.
00046   bool Create( 
00047     const ON_3dPoint& start, 
00048     const ON_3dPoint& end
00049     );
00050 
00051   /*
00052   Description: 
00053     Get line's 3d axis aligned bounding box.
00054   Returns:
00055     3d bounding box.
00056   */
00057   ON_BoundingBox BoundingBox() const;
00058 
00059   /*
00060   Description:
00061     Get line's 3d axis aligned bounding box or the
00062     union of the input box with the object's bounding box.
00063   Parameters:
00064     bbox - [in/out] 3d axis aligned bounding box
00065     bGrowBox - [in] (default=false) 
00066       If true, then the union of the input bbox and the 
00067       object's bounding box is returned in bbox.  
00068       If false, the object's bounding box is returned in bbox.
00069   Returns:
00070     true if object has bounding box and calculation was successful.
00071   */
00072   bool GetBoundingBox(
00073          ON_BoundingBox& bbox,
00074          int bGrowBox = false
00075          ) const;
00076 
00077   /*
00078         Description:
00079     Get tight bounding box.
00080         Parameters:
00081                 tight_bbox - [in/out] tight bounding box
00082                 bGrowBox -[in]  (default=false)                 
00083       If true and the input tight_bbox is valid, then returned
00084       tight_bbox is the union of the input tight_bbox and the 
00085       line's tight bounding box.
00086                 xform -[in] (default=NULL)
00087       If not NULL, the tight bounding box of the transformed
00088       line is calculated.  The line is not modified.
00089         Returns:
00090     True if a valid tight_bbox is returned.
00091   */
00092         bool GetTightBoundingBox( 
00093                         ON_BoundingBox& tight_bbox, 
00094       int bGrowBox = false,
00095                         const ON_Xform* xform = 0
00096       ) const;
00097 
00098   /*
00099   Description:
00100     Get a plane that contains the line.
00101   Parameters:
00102     plane - [out] a plane that contains the line.  The orgin
00103        of the plane is at the start of the line.  The distance
00104        from the end of the line to the plane is <= tolerance.
00105        If possible a plane parallel to the world xy, yz or zx
00106        plane is returned.
00107     tolerance - [in]
00108   Returns:
00109     true if a coordinate of the line's direction vector is
00110     larger than tolerance.
00111   */
00112   bool InPlane( ON_Plane& plane, double tolerance = 0.0 ) const;
00113 
00114   // Returns:
00115   //   Length of line
00116   double Length() const;
00117 
00118   // Returns:
00119   //   direction vector = line.to - line.from
00120   // See Also:
00121   //   ON_Line::Tangent
00122   ON_3dVector Direction() const;
00123 
00124   // Returns:
00125   //   Unit tangent vector.
00126   // See Also:
00127   //   ON_Line::Direction
00128   ON_3dVector Tangent() const;
00129 
00130   /*
00131   Description:
00132     Evaluate point on (infinite) line.
00133   Parameters:
00134     t - [in] evaluation parameter. t=0 returns line.from
00135              and t=1 returns line.to.
00136   Returns:
00137     (1-t)*line.from + t*line.to.
00138   See Also:
00139     ON_Line::Direction
00140     ON_Line::Tangent
00141   */
00142   ON_3dPoint PointAt( 
00143     double t 
00144     ) const;
00145 
00146   /*
00147   Description:
00148     Find the point on the (infinite) line that is
00149     closest to the test_point.
00150   Parameters:
00151     test_point - [in]
00152     t - [out] line.PointAt(*t) is the point on the line 
00153               that is closest to test_point.
00154   Returns:
00155     true if successful.
00156   */
00157   bool ClosestPointTo( 
00158     const ON_3dPoint& test_point, 
00159     double* t
00160     ) const;
00161 
00162   /*
00163   Description:
00164     Find the point on the (infinite) line that is
00165     closest to the test_point.
00166   Parameters:
00167     test_point - [in]
00168   Returns:
00169     The point on the line that is closest to test_point.
00170   */
00171   ON_3dPoint ClosestPointTo( 
00172     const ON_3dPoint& test_point
00173     ) const;
00174 
00175   /*
00176   Description:
00177     Find the point on the (infinite) line that is
00178     closest to the test_point.
00179   Parameters:
00180     test_point - [in]
00181   Returns:
00182     distance from the point on the line that is closest
00183     to test_point.
00184   See Also:
00185     ON_3dPoint::DistanceTo
00186     ON_Line::ClosestPointTo
00187   */
00188   double DistanceTo( ON_3dPoint test_point ) const;
00189 
00190 
00191   /*
00192   Description:
00193     Finds the shortest distance between the line as a finite
00194     chord and the other object.
00195   Parameters:
00196     P - [in]
00197     L - [in] (another finite chord)
00198   Returns:
00199     A value d such that if Q is any point on 
00200     this line and P is any point on the other object, 
00201     then d <= Q.DistanceTo(P).
00202   */
00203   double MinimumDistanceTo( const ON_3dPoint& P ) const;
00204   double MinimumDistanceTo( const ON_Line& L ) const;
00205 
00206   /*
00207   Description:
00208     Finds the longest distance between the line as a finite
00209     chord and the other object.
00210   Parameters:
00211     P - [in]
00212     L - [in] (another finite chord)
00213   Returns:
00214     A value d such that if Q is any point on this line and P is any
00215     point on the other object, then d >= Q.DistanceTo(P).
00216   */
00217   double MaximumDistanceTo( const ON_3dPoint& P ) const;
00218   double MaximumDistanceTo( const ON_Line& other ) const;
00219 
00220 
00221   /*
00222   Description:
00223     Quickly determine if the shortest distance from
00224     this line to the other object is greater than d.
00225   Parameters:
00226     d - [in] distance (> 0.0)
00227     P - [in] 
00228     L - [in] 
00229   Returns:
00230     True if if the shortest distance from this line
00231     to the other object is greater than d.
00232   */
00233   bool IsFartherThan( double d, const ON_3dPoint& P ) const;
00234   bool IsFartherThan( double d, const ON_Line& L ) const;
00235 
00236 
00237   // For intersections see ON_Intersect();
00238 
00239   // Description:
00240   //   Reverse line by swapping from and to.
00241   void Reverse();
00242 
00243   bool Transform( 
00244     const ON_Xform& xform
00245     );
00246 
00247   // rotate line about a point and axis
00248   bool Rotate(
00249         double sin_angle,
00250         double cos_angle,
00251         const ON_3dVector& axis_of_rotation,
00252         const ON_3dPoint& center_of_rotation
00253         );
00254 
00255   bool Rotate(
00256         double angle_in_radians,
00257         const ON_3dVector& axis_of_rotation,
00258         const ON_3dPoint& center_of_rotation
00259         );
00260 
00261   bool Translate(
00262         const ON_3dVector& delta
00263         );
00264 
00265 public:
00266   ON_3dPoint from; // start point
00267   ON_3dPoint to;   // end point
00268 };
00269 
00270 #endif


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