QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_intersect.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(ON_INTERSECT_INC_)
17#define ON_INTERSECT_INC_
18
19// These simple intersectors are fast and detect transverse intersections.
20// If the intersection is not a simple transverse case, then they
21// return false and you will have to use one of the slower but fancier
22// models.
23
24
25/*
26Description:
27 Intersect two lines.
28Parameters:
29 lineA - [in]
30 lineB - [in]
31 double* a - [out]
32 double* b - [out] The shortest distance between the lines is the
33 chord from lineA.PointAt(*a) to lineB.PointAt(*b).
34 tolerance - [in] If > 0.0, then an intersection is reported only
35 if the distance between the points is <= tolerance.
36 If <= 0.0, then the closest point between the lines
37 is reported.
38 bIntersectSegments - [in] if true, the input lines are treated
39 as finite segments. If false, the
40 input lines are treated as infinite lines.
41Returns:
42 True if a closest point can be calculated and the result passes
43 the tolerance parameter test.
44See Also:
45 ON_Intersect( const ON_Line& lineA, const ON_Line& line B)
46Remarks:
47 If the lines are exactly parallel, meaning the system of equations
48 used to find a and b has no numerical solution, then false is returned.
49 If the lines are nearly parallel, which is often numerically true
50 even if you think the lines look exactly parallel, then the
51 closest points are found and true is returned. So, if you
52 care about weeding out "parallel" lines, then you need to
53 do something like the following.
54
55 bool rc = ON_IntersectLineLine(lineA,lineB,
56 &a,&b,
57 tolerance,
58 bIntersectSegments);
59 if (rc)
60 {
61 double angle_tolerance_radians = 0.5*ON_PI/180.0; // or whatever
62 double parallel_tol = cos(angle_tolerance_radians);
63 if ( fabs(lineA.Tangent()*lineB.Tangent()) >= parallel_tol )
64 {
65 ... do whatever you think is appropriate
66 }
67 }
68*/
71 const ON_Line& lineA,
72 const ON_Line& lineB,
73 double* a,
74 double* b,
75 double tolerance,
76 bool bIntersectSegments
77 );
78
79/*
80Description:
81 Find the closest point between two infinte lines.
82Parameters:
83 lineA - [in]
84 lineB - [in]
85 double* a - [out]
86 double* b - [out] The shortest distance between the lines is the
87 chord from lineA.PointAt(*a) to lineB.PointAt(*b).
88Returns:
89 True if points are found and false if the lines are numerically parallel.
90 Numerically parallel means the 2x2 matrix
91
92 AoA -AoB
93 -AoB BoB
94
95 is numerically singluar, where A = lineA.to-lineA.from
96 and B = lineB.to-lineB.from.
97See Also:
98 ON_IntersectLineLine
99*/
101bool ON_Intersect(
102 const ON_Line& lineA,
103 const ON_Line& lineB,
104 double* a,
105 double* b
106 );
107
109bool ON_Intersect( // Returns false unless intersection is a single point
110 // If returned parameter is < 0 or > 1, then the line
111 // segment between line.m_point[0] and line.m_point[1]
112 // does not intersect the plane
113 const ON_Line&,
114 const ON_Plane&,
115 double* // parameter on line
116 );
117
119bool ON_Intersect( const ON_Plane&,
120 const ON_Plane&,
121 ON_Line& // intersection line is returned here
122 );
123
125bool ON_Intersect( const ON_Plane&,
126 const ON_Plane&,
127 const ON_Plane&,
128 ON_3dPoint& // intersection point is returned here
129 );
130
132int ON_Intersect( // returns 0 = no intersections,
133 // 1 = intersection = single point,
134 // 2 = intersection = circle
135 // If 0 is returned, returned circle has radius=0
136 // and center = point on sphere closest to plane.
137 // If 1 is returned, intersection is a single
138 // point and returned circle has radius=0
139 // and center = intersection point on sphere.
140 const ON_Plane&, const ON_Sphere&, ON_Circle&
141 );
142
144int ON_Intersect( // returns 0 = no intersections,
145 // 1 = one intersection,
146 // 2 = 2 intersections
147 // If 0 is returned, first point is point
148 // on line closest to sphere and 2nd point is the point
149 // on the sphere closest to the line.
150 // If 1 is returned, first point is obtained by evaluating
151 // the line and the second point is obtained by evaluating
152 // the sphere.
153 const ON_Line&, const ON_Sphere&,
154 ON_3dPoint&, ON_3dPoint& // intersection point(s) returned here
155 );
156
158int ON_Intersect( // returns 0 = no intersections,
159 // 1 = one intersection,
160 // 2 = 2 intersections
161 // 3 = line lies on cylinder
162 // If 0 is returned, first point is point
163 // on line closest to cylinder and 2nd point is the point
164 // on the sphere closest to the line.
165 // If 1 is returned, first point is obtained by evaluating
166 // the line and the second point is obtained by evaluating
167 // the sphere.
168 const ON_Line&, const ON_Cylinder&,
169 ON_3dPoint&, ON_3dPoint& // intersection point(s) returned here
170 );
171
172/*
173Description:
174 Intersect an infinite line and an axis aligned bounding box.
175Parameters:
176 bbox - [in]
177 line - [in]
178 tolerance - [in] If tolerance > 0.0, then the intersection is
179 performed against a box that has each side
180 moved out by tolerance.
181 line_parameters - [out] The chord from line.PointAt(line_parameters[0])
182 to line.PointAt(line_parameters[1]) is the intersection.
183Returns:
184 True if the line intersects the box and false otherwise.
185*/
187bool ON_Intersect( const ON_BoundingBox& bbox,
188 const ON_Line& line,
189 double tolerance,
190 ON_Interval* line_parameters
191 );
192
193/*
194Description:
195 Intersect two spheres using exact calculations.
196Parameters:
197 sphere0 - [in]
198 sphere1 - [in]
199 circle - [out] If intersection is a point, then that point will be the center, radius 0.
200Returns:
201 0 if no intersection,
202 1 if a single point,
203 2 if a circle,
204 3 if the spheres are the same.
205*/
207int ON_Intersect( const ON_Sphere& sphere0,
208 const ON_Sphere& sphere1,
209 ON_Circle& circle
210 );
211#endif
Definition opennurbs_point.h:403
Definition opennurbs_bounding_box.h:25
Definition opennurbs_circle.h:33
Definition opennurbs_cylinder.h:28
Definition opennurbs_point.h:46
Definition opennurbs_line.h:20
Definition opennurbs_plane.h:20
Definition opennurbs_sphere.h:22
#define ON_DECL
Definition opennurbs_defines.h:92
ON_DECL bool ON_Intersect(const ON_Line &lineA, const ON_Line &lineB, double *a, double *b)
Definition opennurbs_intersect.cpp:202
ON_DECL bool ON_IntersectLineLine(const ON_Line &lineA, const ON_Line &lineB, double *a, double *b, double tolerance, bool bIntersectSegments)
Definition opennurbs_intersect.cpp:19