QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_arc.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_ARC_INC_)
17#define ON_ARC_INC_
18
19/*
20Description:
21 An ON_Arc is a subcurve of 3d circle.
22Details:
23 The curve is parameterized by an angle expressed in radians. For an IsValid() arc
24 the total subtended angle AngleRadians() = Domain()(1) - Domain()(0) must satisfy
25 0< AngleRadians() <2*Pi .
26
27 The parameterization of the ON_Arc is inherited from the ON_Circle it is derived from.
28 In particular
29 t -> center + cos(t)*radius*xaxis + sin(t)*radius*yaxis
30 where xaxis and yaxis, (part of ON_Circle::m_plane) form an othonormal frame of the plane
31 containing the circle.
32*/
34{
35public:
36 // Create a radius one arc with angle = 2*pi
37 ON_Arc();
38
39 ON_Arc(
40 const ON_Circle&,
41 double // angle in radians
42 );
43
44 /*
45 Parameters:
46 circle - [in]
47 angle_interval_in_radians - [in] increasing angle interval
48 in radians with angle_interval_in_radians.Length() <= 2.0*ON_PI.
49 */
50 ON_Arc(
51 const ON_Circle& circle,
52 ON_Interval angle_interval_in_radians
53 );
54
55 ON_Arc(
56 const ON_Plane&, // circle is in this plane with center at m_origin
57 double, // radius
58 double // angle in radians
59 );
60
61 ON_Arc( // arc is parallel to XY plane
62 const ON_3dPoint&, // center
63 double, // radius
64 double // angle in radians
65 );
66
67 ON_Arc( // arc parallel to a plane
68 const ON_Plane&, // circle will be parallel to this plane
69 const ON_3dPoint&, // center
70 double, // radius
71 double // angle in radians
72 );
73
74 ON_Arc( // arc through 3 2d points
75 const ON_2dPoint&, // point P
76 const ON_2dPoint&, // point Q
77 const ON_2dPoint& // point R
78 );
79
80 ON_Arc( // arc through 3 3d points
81 const ON_3dPoint&, // point P
82 const ON_3dPoint&, // point Q
83 const ON_3dPoint& // point R
84 );
85
87 // Create an arc from a circle and an angle in radians
88 bool Create(
89 const ON_Circle&, // [IN]
90 double // [IN] angle in radians
91 );
92
93 /*
94 Description:
95 Create an arc from a circle and an increasing angle interval
96 Parameters:
97 circle - [in]
98 angle_interval_in_radians - [in] increasing angle interval in radians
99 with angle_interval_in_radians.Length() <= 2.0*ON_PI
100 Returns:
101 true if input is valid and a valid arc is created.
102 */
103 bool Create(
104 const ON_Circle& circle,
105 ON_Interval angle_interval_in_radians
106 );
107
109 // Create an arc from a plane, radius and an angle in radians.
110 // The center of the arc is at the plane's origin.
111 bool Create(
112 const ON_Plane&, // [IN] circle is in this plane with center at m_origin
113 double, // [IN] radius
114 double // [IN] angle in radians
115 );
116
118 // Create an arc parallel to the world XY plane from a center point,
119 // radius, and angle in radians. The arc starts at center+(radius,0,0).
120 bool Create(
121 const ON_3dPoint&, // [IN] center
122 double, // [IN] radius
123 double // [IN] angle in radians
124 );
125
127 // Create an arc parallel to plane from a center point, radius,
128 // and angle in radians. The arc starts at center+radius*plane.xaxis.
129 bool Create(
130 const ON_Plane&, // [IN] circle will be parallel to this plane
131 const ON_3dPoint&, // [IN] center
132 double, // [IN] radius
133 double // [IN] angle in radians
134 );
135
137 // Create an arc that passes through 3 2d points.
138 bool Create( // arc through 3 2d points
139 const ON_2dPoint&, // [IN] point P
140 const ON_2dPoint&, // [IN] point Q
141 const ON_2dPoint& // [IN] point R
142 );
143
145 // Create an arc that passes through 3 3d points.
146 bool Create( // arc through 3 3d points
147 const ON_3dPoint&, // [IN] point P
148 const ON_3dPoint&, // [IN] point Q
149 const ON_3dPoint& // [IN] point R
150 );
151
153 // Create an arc from a 2d start point, 2d start direction, and 2d end point.
154 bool Create(
155 const ON_2dPoint&, // [IN] point P
156 const ON_2dVector&, // [IN] arc direction at P
157 const ON_2dPoint& // [IN] point R
158 );
159
161 // Create an arc from a 3d start point, 3d start direction, and 3d end point.
162 bool Create(
163 const ON_3dPoint&, // [IN] point P
164 const ON_3dVector&, // [IN] arc direction at P
165 const ON_3dPoint& // [IN] point R
166 );
167
168 ON_Arc& operator=( const ON_Circle& );
169
170
171 ~ON_Arc();
172
173 // Description:
174 // Creates a text dump of the arc listing the normal, center
175 // radius, start point, end point, and angle.
176 // Remarks:
177 // Dump() is intended for debugging and is not suitable
178 // for creating high quality text descriptions of an
179 // arc.
180 void Dump( ON_TextLog& dump ) const;
181
182 // Description:
183 // Checks an arc to make sure it is valid.
184 // Detail:
185 // Radius>0 and 0<AngleRadians()<=2 ON_PI
186 // Returns:
187 // true if the arc is valid.
188 bool IsValid() const;
189
190 // Description:
191 // Get arc's 3d axis aligned bounding box.
192 // Returns:
193 // 3d bounding box.
195
196 // Description:
197 // Get arc's 3d axis aligned bounding box or the
198 // union of the input box with the arc's bounding box.
199 // Parameters:
200 // bbox - [in/out] 3d axis aligned bounding box
201 // bGrowBox - [in] (default=false)
202 // If true, then the union of the input bbox and the
203 // arc's bounding box is returned in bbox.
204 // If false, the arc's bounding box is returned in bbox.
205 // Returns:
206 // true if arc has bounding box and calculation was successful.
207 bool GetBoundingBox(
208 ON_BoundingBox& bbox,
209 int bGrowBox = false
210 ) const;
211
212 /*
213 Description:
214 Get tight bounding box.
215 Parameters:
216 tight_bbox - [in/out] tight bounding box
217 bGrowBox -[in] (default=false)
218 If true and the input tight_bbox is valid, then returned
219 tight_bbox is the union of the input tight_bbox and the
220 arc's tight bounding box.
221 xform -[in] (default=NULL)
222 If not NULL, the tight bounding box of the transformed
223 arc is calculated. The arc is not modified.
224 Returns:
225 True if a valid tight_bbox is returned.
226 */
228 ON_BoundingBox& tight_bbox,
229 int bGrowBox = false,
230 const ON_Xform* xform = 0
231 ) const;
232
233 // Returns:
234 // true if the arc is a complete circle; i.e., the arc's
235 // angle is 360 degrees.
236 bool IsCircle() const;
237
238 // Returns:
239 // The arc's subtended angle in radians.
240 double AngleRadians() const;
241
242 // Returns:
243 // The arc's subtended angle in degrees.
244 double AngleDegrees() const;
245
246
247 /*
248 Description:
249 Get evaluation domain.
250 Returns:
251 Evaluation domain (same as DomainRadians()).
252 */
253 ON_Interval Domain() const;
254
255 // Returns:
256 // The arc's domain in radians.
257 ON_Interval DomainRadians() const;
258
259 // Returns:
260 // The arc's domain in degrees.
261 ON_Interval DomainDegrees() const;
262
263 // Description:
264 // Set arc's subtended angle in radians.
265 // Parameters:
266 // angle_in_radians - [in] 0 <= angle_in_radians <= 2.0*ON_PI
267 //
268 bool SetAngleRadians(
269 double angle_in_radians
270 );
271
272 /*
273 Description:
274 Set arc's angle interval in radians.
275 Parameters:
276 angle_in_radians - [in] increasing interval with
277 start and end angle in radians.
278 Length of the interval <= 2.0*ON_PI.
279 Returns:
280 true if successful.
281 */
282 bool SetAngleIntervalRadians(
283 ON_Interval angle_in_radians
284 );
285
286 // Description:
287 // Set arc's domain as a subdomain of the circle.
288 // Parameters:
289 // domain_radian - [in] 0 < domain_radian[1] - domain_radian[0] <= 2.0 * ON*PI
290 //
291 bool Trim(
292 ON_Interval domain_radian
293 );
294
295 // Description:
296 // Set arc's subtended angle in degrees.
297 // Parameters:
298 // angle_in_degrees - [in] 0 < angle_in_degrees <= 360
299 bool SetAngleDegrees(
300 double angle_in_degrees
301 );
302
303 // Returns:
304 // Point at start of the arc.
305 ON_3dPoint StartPoint() const;
306
307
308 // Returns:
309 // Point at middle of the arc.
310 ON_3dPoint MidPoint() const;
311
312 // Returns:
313 // Point at end of the arc.
314 ON_3dPoint EndPoint() const;
315
316 // Description:
317 // Get the point on the arc that is closest to test_point.
318 // Parameters:
319 // test_point - [in]
320 // t - [out] parameter (in radians) of the point on the arc that
321 // is closest to test_point. If test_point is the center
322 // of the arc, then the starting point of the arc is
323 // (arc.Domain()[0]) returned.
324 bool ClosestPointTo(
325 const ON_3dPoint& test_point,
326 double* t
327 ) const;
328
329 // Description:
330 // Get the point on the arc that is closest to test_point.
331 // Parameters:
332 // test_point - [in]
333 // Returns:
334 // The point on the arc that is closest to test_point.
335 // If test_point is the center of the arc, then the
336 // starting point of the arc is returned.
338 const ON_3dPoint& test_point
339 ) const;
340
341 // Returns:
342 // Length of the arc = radius*(subtended angle in radians).
343 double Length() const;
344
345 // Description:
346 // Reverse the orientation of the arc. Changes the domain
347 // from [a,b] to [-b.-a].
348 bool Reverse();
349
350 // Description:
351 // Get a rational degree 2 NURBS curve representation
352 // of the arc. Note that the parameterization of NURBS curve
353 // does not match arc's transcendental paramaterization.
354 // Use GetRadianFromNurbFormParameter() and
355 // GetParameterFromRadian() to convert between the NURBS curve
356 // parameter and the transcendental parameter
357 // Parameters:
358 // nurbs_curve - [out] nurbs_curve returned here.
359 // Returns:
360 // 0 for failure and 2 for success.
361 int GetNurbForm(
362 ON_NurbsCurve& nurbs_curve
363 ) const;
364
365 /*
366 Description:
367 Convert a NURBS curve arc parameter to a arc radians parameter.
368 Parameters:
369 nurbs_parameter - [in]
370 arc_radians_parameter - [out]
371 Example:
372
373 ON_Arc arc = ...;
374 double nurbs_t = 1.2345; // some number in interval (0,2.0*ON_PI).
375 double arc_t;
376 arc.GetRadianFromNurbFormParameter( nurbs_t, &arc_t );
377
378 ON_NurbsCurve nurbs_curve;
379 arc.GetNurbsForm( nurbs_curve );
380 arc_pt = arc.PointAt(arc_t);
381 nurbs_pt = nurbs_curve.PointAt(nurbs_t);
382 // arc_pt and nurbs_pt will be the same
383
384 Remarks:
385 The NURBS curve parameter is with respect to the NURBS curve
386 created by ON_Arc::GetNurbForm. At nurbs parameter values of
387 0.0, 0.5*ON_PI, ON_PI, 1.5*ON_PI, and 2.0*ON_PI, the nurbs
388 parameter and radian parameter are the same. At all other
389 values the nurbs and radian parameter values are different.
390 See Also:
391 ON_Arc::GetNurbFormParameterFromRadian
392 */
394 double nurbs_parameter,
395 double* arc_radians_parameter
396 ) const;
397
398 /*
399 Description:
400 Convert a arc radians parameter to a NURBS curve arc parameter.
401 Parameters:
402 arc_radians_parameter - [in] 0.0 to 2.0*ON_PI
403 nurbs_parameter - [out]
404 Example:
405
406 ON_Arc arc = ...;
407 double arc_t = 1.2345; // some number in interval (0,2.0*ON_PI).
408 double nurbs_t;
409 arc.GetNurbFormParameterFromRadian( arc_t, &nurbs_t );
410
411 ON_NurbsCurve nurbs_curve;
412 arc.GetNurbsForm( nurbs_curve );
413 arc_pt = arc.PointAt(arc_t);
414 nurbs_pt = nurbs_curve.PointAt(nurbs_t);
415 // arc_pt and nurbs_pt will be the same
416
417 Remarks:
418 The NURBS curve parameter is with respect to the NURBS curve
419 created by ON_Arc::GetNurbForm. At radian values of
420 0.0, 0.5*ON_PI, ON_PI, 1.5*ON_PI, and 2.0*ON_PI, the nurbs
421 parameter and radian parameter are the same. At all other
422 values the nurbs and radian parameter values are different.
423 See Also:
424 ON_Arc::GetNurbFormParameterFromRadian
425 */
427 double arc_radians_parameter,
428 double* nurbs_parameter
429 ) const;
430
431private:
433 friend bool ON_BinaryArchive::WriteArc( const ON_Arc& );
434
435 // increasing interval with start and end angle in radians
437};
438
439#endif
440
Definition opennurbs_point.h:253
Definition opennurbs_point.h:655
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_arc.h:34
ON_Interval m_angle
Definition opennurbs_arc.h:436
bool ReadArc(ON_Arc &)
Definition opennurbs_archive.cpp:794
bool WriteArc(const ON_Arc &)
Definition opennurbs_archive.cpp:785
Definition opennurbs_bounding_box.h:25
Definition opennurbs_circle.h:33
bool Reverse()
Definition opennurbs_circle.cpp:531
bool Create(const ON_Plane &plane, double radius)
Definition opennurbs_circle.cpp:218
bool GetTightBoundingBox(ON_BoundingBox &tight_bbox, int bGrowBox=false, const ON_Xform *xform=0) const
Definition opennurbs_bezier.cpp:788
bool GetRadianFromNurbFormParameter(double nurbs_parameter, double *circle_radians_parameter) const
Definition opennurbs_circle.cpp:579
ON_BoundingBox BoundingBox() const
Definition opennurbs_circle.cpp:80
int GetNurbForm(ON_NurbsCurve &nurbs_curve) const
Definition opennurbs_circle.cpp:542
bool GetNurbFormParameterFromRadian(double circle_radians_parameter, double *nurbs_parameter) const
Definition opennurbs_circle.cpp:591
bool IsValid() const
Definition opennurbs_circle.cpp:361
bool ClosestPointTo(const ON_3dPoint &point, double *t) const
Definition opennurbs_circle.cpp:422
Definition opennurbs_point.h:46
Definition opennurbs_nurbscurve.h:27
Definition opennurbs_plane.h:20
Definition opennurbs_textlog.h:20
Definition opennurbs_xform.h:28
Trims an entity to another entity or trims both entities if this.trimBoth is true.
Definition Trim.js:12
#define ON_CLASS
Definition opennurbs_defines.h:91