QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_line.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_LINE_INC_)
17#define ON_LINE_INC_
18
20{
21public:
22
23 ON_Line();
24 ON_Line( const ON_3dPoint& start, const ON_3dPoint& end );
25 ~ON_Line();
26
27 /*
28 Returns:
29 True if from != to.
30 */
31 bool IsValid() const;
32
33 // line[0] = start point line[1] = end point
34 ON_3dPoint& operator[](int);
35 const ON_3dPoint& operator[](int) const;
36
37
38 // Description:
39 // Create a line from two points.
40 // Parameters:
41 // start - [in] point at start of line segment
42 // end - [in] point at end of line segment
43 // Returns:
44 // true if start and end are distinct points.
45 bool Create(
46 const ON_3dPoint& start,
47 const ON_3dPoint& end
48 );
49
50 /*
51 Description:
52 Get line's 3d axis aligned bounding box.
53 Returns:
54 3d bounding box.
55 */
56 ON_BoundingBox BoundingBox() const;
57
58 /*
59 Description:
60 Get line's 3d axis aligned bounding box or the
61 union of the input box with the object's bounding box.
62 Parameters:
63 bbox - [in/out] 3d axis aligned bounding box
64 bGrowBox - [in] (default=false)
65 If true, then the union of the input bbox and the
66 object's bounding box is returned in bbox.
67 If false, the object's bounding box is returned in bbox.
68 Returns:
69 true if object has bounding box and calculation was successful.
70 */
71 bool GetBoundingBox(
72 ON_BoundingBox& bbox,
73 int bGrowBox = false
74 ) const;
75
76 /*
77 Description:
78 Get tight bounding box.
79 Parameters:
80 tight_bbox - [in/out] tight bounding box
81 bGrowBox -[in] (default=false)
82 If true and the input tight_bbox is valid, then returned
83 tight_bbox is the union of the input tight_bbox and the
84 line's tight bounding box.
85 xform -[in] (default=NULL)
86 If not NULL, the tight bounding box of the transformed
87 line is calculated. The line is not modified.
88 Returns:
89 True if a valid tight_bbox is returned.
90 */
91 bool GetTightBoundingBox(
92 ON_BoundingBox& tight_bbox,
93 int bGrowBox = false,
94 const ON_Xform* xform = 0
95 ) const;
96
97 /*
98 Description:
99 Get a plane that contains the line.
100 Parameters:
101 plane - [out] a plane that contains the line. The orgin
102 of the plane is at the start of the line. The distance
103 from the end of the line to the plane is <= tolerance.
104 If possible a plane parallel to the world xy, yz or zx
105 plane is returned.
106 tolerance - [in]
107 Returns:
108 true if a coordinate of the line's direction vector is
109 larger than tolerance.
110 */
111 bool InPlane( ON_Plane& plane, double tolerance = 0.0 ) const;
112
113 // Returns:
114 // Length of line
115 double Length() const;
116
117 // Returns:
118 // direction vector = line.to - line.from
119 // See Also:
120 // ON_Line::Tangent
121 ON_3dVector Direction() const;
122
123 // Returns:
124 // Unit tangent vector.
125 // See Also:
126 // ON_Line::Direction
127 ON_3dVector Tangent() const;
128
129 /*
130 Description:
131 Evaluate point on (infinite) line.
132 Parameters:
133 t - [in] evaluation parameter. t=0 returns line.from
134 and t=1 returns line.to.
135 Returns:
136 (1-t)*line.from + t*line.to.
137 See Also:
138 ON_Line::Direction
139 ON_Line::Tangent
140 */
141 ON_3dPoint PointAt(
142 double t
143 ) const;
144
145 /*
146 Description:
147 Find the point on the (infinite) line that is
148 closest to the test_point.
149 Parameters:
150 test_point - [in]
151 t - [out] line.PointAt(*t) is the point on the line
152 that is closest to test_point.
153 Returns:
154 true if successful.
155 */
156 bool ClosestPointTo(
157 const ON_3dPoint& test_point,
158 double* t
159 ) const;
160
161 /*
162 Description:
163 Find the point on the (infinite) line that is
164 closest to the test_point.
165 Parameters:
166 test_point - [in]
167 Returns:
168 The point on the line that is closest to test_point.
169 */
170 ON_3dPoint ClosestPointTo(
171 const ON_3dPoint& test_point
172 ) const;
173
174 /*
175 Description:
176 Find the point on the (infinite) line that is
177 closest to the test_point.
178 Parameters:
179 test_point - [in]
180 Returns:
181 distance from the point on the line that is closest
182 to test_point.
183 See Also:
184 ON_3dPoint::DistanceTo
185 ON_Line::ClosestPointTo
186 */
187 double DistanceTo( ON_3dPoint test_point ) const;
188
189
190 /*
191 Description:
192 Finds the shortest distance between the line as a finite
193 chord and the other object.
194 Parameters:
195 P - [in]
196 L - [in] (another finite chord)
197 Returns:
198 A value d such that if Q is any point on
199 this line and P is any point on the other object,
200 then d <= Q.DistanceTo(P).
201 */
202 double MinimumDistanceTo( const ON_3dPoint& P ) const;
203 double MinimumDistanceTo( const ON_Line& L ) const;
204
205 /*
206 Description:
207 Finds the longest distance between the line as a finite
208 chord and the other object.
209 Parameters:
210 P - [in]
211 L - [in] (another finite chord)
212 Returns:
213 A value d such that if Q is any point on this line and P is any
214 point on the other object, then d >= Q.DistanceTo(P).
215 */
216 double MaximumDistanceTo( const ON_3dPoint& P ) const;
217 double MaximumDistanceTo( const ON_Line& other ) const;
218
219
220 /*
221 Description:
222 Quickly determine if the shortest distance from
223 this line to the other object is greater than d.
224 Parameters:
225 d - [in] distance (> 0.0)
226 P - [in]
227 L - [in]
228 Returns:
229 True if if the shortest distance from this line
230 to the other object is greater than d.
231 */
232 bool IsFartherThan( double d, const ON_3dPoint& P ) const;
233 bool IsFartherThan( double d, const ON_Line& L ) const;
234
235
236 // For intersections see ON_Intersect();
237
238 // Description:
239 // Reverse line by swapping from and to.
240 void Reverse();
241
242 bool Transform(
243 const ON_Xform& xform
244 );
245
246 // rotate line about a point and axis
247 bool Rotate(
248 double sin_angle,
249 double cos_angle,
250 const ON_3dVector& axis_of_rotation,
251 const ON_3dPoint& center_of_rotation
252 );
253
254 bool Rotate(
255 double angle_in_radians,
256 const ON_3dVector& axis_of_rotation,
257 const ON_3dPoint& center_of_rotation
258 );
259
260 bool Translate(
261 const ON_3dVector& delta
262 );
263
264 /*
265 Description:
266 Intersect infinite line with surfaceB.
267 Parameters:
268 surfaceB - [in]
269 x - [out] Intersection events are appended to this array.
270 intersection_tolerance - [in] If the distance from a point
271 on this line to the surface is <= intersection tolerance,
272 then the point will be part of an intersection event.
273 If the input intersection_tolerance <= 0.0, then 0.001 is used.
274 overlap_tolerance - [in] If t1 and t2 are curve parameters of
275 intersection events and the distance from line(t) to the
276 surface is <= overlap_tolerance for every t1 <= t <= t2,
277 then the event will be returened as an overlap event.
278 If the input overlap_tolerance <= 0.0, then
279 intersection_tolerance*2.0 is used.
280 line_domain - [in] optional restriction on line's domain
281 If you want a finite intersection, then specify a
282 line_domain. If you want a ray intersection, then specify
283 a line domain like (0.0, ON_DBL_MAX).
284 surfaceB_udomain - [in] optional restriction on surfaceB u domain
285 surfaceB_vdomain - [in] optional restriction on surfaceB v domain
286 Returns:
287 Number of intersection events appended to x.
288 */
289 int IntersectSurface(
290 const class ON_Surface* surfaceB,
292 double intersection_tolerance = 0.0,
293 double overlap_tolerance = 0.0,
294 const ON_Interval* line_domain = 0,
295 const ON_Interval* surfaceB_udomain = 0,
296 const ON_Interval* surfaceB_vdomain = 0
297 ) const;
298
299
300public:
301 ON_3dPoint from; // start point
302 ON_3dPoint to; // end point
303};
304
305#endif
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_bounding_box.h:25
Definition opennurbs_point.h:46
Definition opennurbs_line.h:20
ON_3dPoint to
Definition opennurbs_line.h:302
ON_3dPoint from
Definition opennurbs_line.h:301
Definition opennurbs_plane.h:20
Definition opennurbs_array.h:46
Definition opennurbs_surface.h:58
Definition opennurbs_xform.h:28
Reverses all selected entities which support reversing (lines, arcs, splines).
Definition Reverse.js:11
Rotates selected entities.
Definition Rotate.js:11
Translates (moves or copies) selected entities.
Definition Translate.js:11
#define ON_CLASS
Definition opennurbs_defines.h:91