opennurbs_intersect.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_INTERSECT_INC_)
00018 #define ON_INTERSECT_INC_
00019 
00020 // These simple intersectors are fast and detect transverse intersections.
00021 // If the intersection is not a simple transverse case, then they
00022 // return false and you will have to use one of the slower but fancier
00023 // models.
00024 
00025 
00026 /*
00027 Description:
00028   Intersect two lines.
00029 Parameters:
00030   lineA - [in]
00031   lineB - [in]
00032   double* a - [out]
00033   double* b - [out] The shortest distance between the lines is the
00034                    chord from lineA.PointAt(*a) to lineB.PointAt(*b).
00035   tolerance - [in] If > 0.0, then an intersection is reported only
00036                    if the distance between the points is <= tolerance.
00037                    If <= 0.0, then the closest point between the lines
00038                    is reported.
00039   bIntersectSegments - [in] if true, the input lines are treated
00040                            as finite segments.  If false, the
00041                            input lines are treated as infinite lines.
00042 Returns:
00043   True if a closest point can be calculated and the result passes
00044   the tolerance parameter test.
00045 See Also:
00046   ON_Intersect( const ON_Line& lineA, const ON_Line& line B)
00047 Remarks:
00048   If the lines are exactly parallel, meaning the system of equations
00049   used to find a and b has no numerical solution, then false is returned.
00050   If the lines are nearly parallel, which is often numerically true
00051   even if you think the lines look exactly parallel, then the
00052   closest points are found and true is returned.  So, if you
00053   care about weeding out "parallel" lines, then you need to
00054   do something like the following.
00055 
00056           bool rc = ON_IntersectLineLine(lineA,lineB,
00057                                          &a,&b,
00058                                          tolerance,
00059                                          bIntersectSegments);
00060           if (rc)
00061           {
00062             double angle_tolerance_radians = 0.5*ON_PI/180.0; // or whatever
00063             double parallel_tol = cos(angle_tolerance_radians);
00064             if ( fabs(lineA.Tangent()*lineB.Tangent()) >= parallel_tol )
00065             {
00066               ... do whatever you think is appropriate
00067             }
00068           }
00069 */
00070 ON_DECL
00071 bool ON_IntersectLineLine(
00072           const ON_Line& lineA, 
00073           const ON_Line& lineB, 
00074           double* a,
00075           double* b,
00076           double tolerance,
00077           bool bIntersectSegments
00078           );
00079 
00080 /*
00081 Description:
00082   Find the closest point between two infinte lines.
00083 Parameters:
00084   lineA - [in]
00085   lineB - [in]
00086   double* a - [out]
00087   double* b - [out] The shortest distance between the lines is the
00088                    chord from lineA.PointAt(*a) to lineB.PointAt(*b).
00089 Returns:
00090   True if points are found and false if the lines are numerically parallel.
00091   Numerically parallel means the 2x2 matrix
00092 
00093             AoA  -AoB
00094            -AoB   BoB
00095 
00096  is numerically singluar, where A = lineA.to-lineA.from 
00097  and B = lineB.to-lineB.from.
00098 See Also:
00099   ON_IntersectLineLine
00100 */
00101 ON_DECL
00102 bool ON_Intersect(
00103           const ON_Line& lineA, 
00104           const ON_Line& lineB, 
00105           double* a,
00106           double* b
00107           );
00108 
00109 ON_DECL
00110 bool ON_Intersect( // Returns false unless intersection is a single point
00111                    // If returned parameter is < 0 or > 1, then the line
00112                    // segment between line.m_point[0] and line.m_point[1]
00113                    // does not intersect the plane
00114           const ON_Line&, 
00115           const ON_Plane&, 
00116           double* // parameter on line
00117           );
00118 
00119 ON_DECL
00120 bool ON_Intersect( const ON_Plane&, 
00121                   const ON_Plane&, 
00122                    ON_Line& // intersection line is returned here
00123                    );
00124 
00125 ON_DECL
00126 bool ON_Intersect( const ON_Plane&, 
00127                   const ON_Plane&, 
00128                   const ON_Plane&,
00129                   ON_3dPoint& // intersection point is returned here
00130                   );
00131 
00132 /*
00133 Description:
00134   Intersect a plane and a sphere.
00135 Parameters:
00136   plane - [in]
00137   sphere - [in]
00138   circle - [out]
00139 Returns:
00140   0: no intersection
00141     circle radius = 0 and circle origin = point on the plane
00142     closest to the sphere.
00143   1: intersection is a single point
00144     circle radius = 0;
00145   2: intersection is a circle
00146     circle radius > 0.
00147 */
00148 ON_DECL
00149 int ON_Intersect(
00150           const ON_Plane& plane, 
00151           const ON_Sphere& sphere,
00152           ON_Circle& circle
00153           );
00154 
00155 ON_DECL
00156 int ON_Intersect( // returns 0 = no intersections, 
00157                   // 1 = one intersection, 
00158                   // 2 = 2 intersections
00159                   // If 0 is returned, first point is point 
00160                   // on line closest to sphere and 2nd point is the point
00161                   // on the sphere closest to the line.
00162                   // If 1 is returned, first point is obtained by evaluating
00163                   // the line and the second point is obtained by evaluating
00164                   // the sphere.
00165                  const ON_Line&, const ON_Sphere&,
00166                   ON_3dPoint&, ON_3dPoint& // intersection point(s) returned here
00167                   );
00168 
00169 ON_DECL
00170 int ON_Intersect( // returns 0 = no intersections, 
00171                   // 1 = one intersection, 
00172                   // 2 = 2 intersections
00173                   // 3 = line lies on cylinder
00174                   // If 0 is returned, first point is point 
00175                   // on line closest to cylinder and 2nd point is the point
00176                   // on the sphere closest to the line.
00177                   // If 1 is returned, first point is obtained by evaluating
00178                   // the line and the second point is obtained by evaluating
00179                   // the sphere.
00180                   const ON_Line&, const ON_Cylinder&,
00181                   ON_3dPoint&, ON_3dPoint& // intersection point(s) returned here
00182                   );
00183 
00184 /*
00185 Description:
00186   Intersect an infinite line and an axis aligned bounding box.
00187 Parameters:
00188   bbox - [in]
00189   line - [in]
00190   tolerance - [in]  If tolerance > 0.0, then the intersection is
00191                    performed against a box that has each side
00192                    moved out by tolerance.
00193   line_parameters - [out] 
00194     Pass null if you do not need the parameters.
00195     If true is returned and line.from != line.to,
00196     then the chord from line.PointAt(line_parameters[0])
00197     to line.PointAt(line_parameters[1]) is the intersection.
00198     If true is returned and line.from = line.to, then line.from
00199     is in the box and the interval (0.0,0.0) is returned.
00200     If false is returned, the input value of line_parameters
00201     is not changed.
00202 Returns:
00203   True if the line intersects the box and false otherwise.
00204 */
00205 ON_DECL
00206 bool ON_Intersect( const ON_BoundingBox& bbox, 
00207                    const ON_Line& line, 
00208                    double tolerance,
00209                    ON_Interval* line_parameters
00210                    );
00211 
00212 /*
00213 Description:
00214   Intersect two spheres using exact calculations.
00215 Parameters:
00216   sphere0 - [in]
00217   sphere1 - [in]
00218   circle - [out] If intersection is a point, then that point will be the center, radius 0.
00219 Returns:
00220   0 if no intersection,
00221   1 if a single point,
00222   2 if a circle,
00223   3 if the spheres are the same.
00224 */
00225 ON_DECL
00226 int ON_Intersect( const ON_Sphere& sphere0, 
00227                   const ON_Sphere& sphere1, 
00228                   ON_Circle& circle
00229                  );
00230 #endif


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