QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_plane.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_PLANE_INC_)
17#define ON_PLANE_INC_
18
20{
21public:
22
23 /*
24 Description:
25 The default constructor creates a plane
26 with orgin=(0,0,0), xaxis=(1,0,0), yaxis=(0,1,0)
27 zaxis=(0,0,1), and equation=(0,0,1,0).
28 */
29 ON_Plane();
30
31 /*
32 Description:
33 Construct a plane from a point and normal vector.
34 Parameters:
35 origin - [in] point on the plane
36 normal - [in] non-zero normal to the plane
37 Remarks:
38 origin = point, zaxis = unitized normal, xaxis
39 xaxis set with xaxis.PerpindicularTo(zaxis).
40 See Also:
41 ON_Plane::CreateFromNormal
42 */
44 const ON_3dPoint& origin,
45 const ON_3dVector& normal
46 );
47
48 /*
49 Description:
50 Construct a plane from a point, and two vectors in
51 the plane.
52 Parameters:
53 origin - [in] point on the plane
54 x_dir - [in] non-zero vector in the plane that
55 determines the xaxis direction.
56 y_dir - [in] non-zero vector not parallel to x_dir
57 that is used to determine the yaxis direction.
58 y_dir does not have to be perpindicular to x_dir.
59 */
61 const ON_3dPoint& origin,
62 const ON_3dVector& x_dir,
63 const ON_3dVector& y_dir
64 );
65
66 /*
67 Description:
68 Construct a plane from three non-colinear points.
69 Parameters:
70 origin - [in] point on the plane
71 x_point - [in] second point in the plane.
72 The xaxis will be parallel to x_point-origin.
73 y_point - [in] third point on the plane that is
74 not colinear with the first two points.
75 yaxis*(y_point-origin) will be > 0.
76 */
78 const ON_3dPoint& origin,
79 const ON_3dPoint& x_point,
80 const ON_3dPoint& y_point
81 );
82
83 /*
84 Description:
85 Construct a plane from an equation.
86 Parameters:
87 equation - [in] an array of 4 doubles with
88 one of equation[0], equation[1], or equation[2]
89 being non-zero.
90 */
92 const double equation[4]
93 );
94
95 ~ON_Plane();
96
97 bool operator==(const ON_Plane&) const;
98 bool operator!=(const ON_Plane&) const;
99
100 /*
101 Description:
102 Create a plane from a point and normal vector.
103 Parameters:
104 origin - [in] point on the plane
105 normal - [in] non-zero normal to the plane
106 Remarks:
107 origin = point, zaxis = unitized normal, xaxis
108 xaxis set with xaxis.PerpindicularTo(zaxis).
109 Returns:
110 true if valid plane is created.
111 */
112 bool CreateFromNormal(
113 const ON_3dPoint& origin,
114 const ON_3dVector& normal
115 );
116
117 /*
118 Description:
119 Construct a plane from a point, and two vectors in
120 the plane.
121 Parameters:
122 origin - [in] point on the plane
123 x_dir - [in] non-zero vector in the plane that
124 determines the xaxis direction.
125 y_dir - [in] non-zero vector not parallel to x_dir
126 that is used to determine the yaxis direction.
127 y_dir does not have to be perpindicular to x_dir.
128 Returns:
129 true if valid plane is created.
130 */
131 bool CreateFromFrame(
132 const ON_3dPoint& origin,
133 const ON_3dVector& x_dir,
134 const ON_3dVector& y_dir
135 );
136
137 /*
138 Description:
139 Construct a plane from three non-colinear points.
140 Parameters:
141 origin - [in] point on the plane
142 point_on_x - [in] second point in the plane.
143 The xaxis will be parallel to x_point-origin.
144 point_on - [in] third point on the plane that is
145 not colinear with the first two points.
146 yaxis*(y_point-origin) will be > 0.
147 Returns:
148 true if valid plane is created.
149 */
150 bool CreateFromPoints(
151 const ON_3dPoint& origin,
152 const ON_3dPoint& point_on_x,
153 const ON_3dPoint& point_on
154 );
155
156 /*
157 Description:
158 Construct a plane from an equation.
159 Parameters:
160 equation - [in] an array of 4 doubles with
161 one of equation[0], equation[1], or equation[2]
162 being non-zero.
163 Remarks:
164 points on the plane will satisfy
165 x*equation[0] +y*equation[1] + z*equation[2] + equation[3] = 0
166 Returns:
167 true if valid plane is created.
168 */
169 bool CreateFromEquation(
170 const double equation[4]
171 );
172
173 /*
174 Description:
175 Test plane to see if it is valid.
176 Returns:
177 true if all fields contain reasonable
178 information and equation jibes with point and zaxis.
179 */
180 bool IsValid() const;
181
182 /*
183 Returns:
184 Plane origin.
185 */
186 const ON_3dPoint& Origin() const;
187
188 /*
189 Returns:
190 Plane unit x-axis.
191 */
192 const ON_3dVector& Xaxis() const;
193
194 /*
195 Returns:
196 Plane unit y-axis.
197 */
198 const ON_3dVector& Yaxis() const;
199
200 /*
201 Returns:
202 Plane unit normal.
203 */
204 const ON_3dVector& Normal() const;
205
206
207 /*
208 Description:
209 Set the origin and update the plane equation
210 Parameters:
211 origin - [in] the new origin
212 */
213 void SetOrigin( const ON_3dPoint& origin );
214
215 /*
216 Description:
217 Evaluate a point on the plane
218 Parameters:
219 u - [in]
220 v - [in] evaulation parameters
221 Returns:
222 plane.origin + u*plane.xaxis + v*plane.yaxis
223 */
224 ON_3dPoint PointAt(
225 double u,
226 double v
227 ) const;
228
229 /*
230 Description:
231 Evaluate a point on the plane
232 Parameters:
233 u - [in]
234 v - [in] evaluation parameters
235 w - [in] elevation parameter
236 Returns:
237 plane.origin + u*plane.xaxis + v*plane.yaxis + z*plane.zaxis
238 */
239 ON_3dPoint PointAt(
240 double u,
241 double v,
242 double w
243 ) const;
244
245 /*
246 Description:
247 Get an isoparameteric line on the plane.
248 Parameters:
249 dir - [in] direction of iso-parametric line
250 0: first parameter varies and second parameter is constant
251 e.g., line(t) = plane(t,c)
252 1: first parameter is constant and second parameter varies
253 e.g., line(t) = plane(c,t)
254 c - [in] value of constant parameter
255 Returns:
256 iso-parametric line
257 */
258 ON_Line IsoLine(
259 int dir,
260 double c
261 ) const;
262
263 /*
264 Description:
265 Get signed distance from the plane to a point.
266 Parameters:
267 point - [in]
268 Returns:
269 Signed distance from a point to a plane.
270 Remarks:
271 If the point is on the plane, the distance is 0.
272 If the point is above the plane, the distance is > 0.
273 If the point is below the plane the distance is < 0.
274 The zaxis determines the plane's orientation.
275 */
276 double DistanceTo(
277 const ON_3dPoint& point
278 ) const;
279
280
281 bool GetDistanceToBoundingBox(
282 //returns false if plane has zero length normal
283 const ON_BoundingBox&, // Box
284
285 //output
286 double* min, // min signed dist from plane to box
287 double* max //max signed dist from plane to box
288 ) const;
289
290 // OBSOLETE - use plane_equation.ValueAt()
291 //__declspec(deprecated) double EquationAt(
292 // const ON_3dPoint& point
293 // ) const;
294
295 // OBSOLETE - use plane_equation.ValueAt()
296 //__declspec(deprecated) double EquationAt(
297 // const ON_4dPoint& point
298 // ) const;
299
300 /*
301 Description:
302 Update the plane equation based on the current values
303 of the origin and zaxis.
304 Returns:
305 true if successful. false if zaxis is zero.
306 Remarks:
307 If you modify a plane's origin or zaxis, call UpdateEquation()
308 to set equation[].
309 */
310 bool UpdateEquation();
311
312 /*
313 Description:
314 Get point on plane that is closest to a given point.
315 Parameters:
316 world_point - [in] 3d point
317 u - [out]
318 v - [out] The point ON_Plane::PointAt(*u,*v) is the point
319 on the plane that is closest to world_point.
320 Returns:
321 true if successful.
322 */
323 bool ClosestPointTo(
324 ON_3dPoint world_point,
325 double* u,
326 double* v
327 ) const;
328
329 /*
330 Description:
331 Get point on plane that is closest to a given point.
332 Parameters:
333 point - [in]
334 Returns:
335 A 3d point on the plane that is closest to world_point.
336 */
337 ON_3dPoint ClosestPointTo(
338 ON_3dPoint point
339 ) const;
340
341 // For intersections see ON_Intersect();
342
343 /*
344 Description:
345 Transform plane.
346 Parameters:
347 xform - [in] transformation to apply to plane
348 Returns:
349 true if successful
350 */
351 bool Transform(
352 const ON_Xform& xform
353 );
354
355 /*
356 Description:
357 Morph plane.
358 Parameters:
359 morph - [in] morph to apply to plane
360 Returns:
361 true if successful
362 Remarks:
363 The resulting plane still has an orthonormal frame
364 */
365 bool Morph( const ON_SpaceMorph& morph );
366
367 /*
368 Description:
369 Transform a plane by swapping coordinates.
370 Parameters:
371 i - [in]
372 j - [in] indices of coordinates to swap.
373 0 = x coordinate, 1 = y coordinate, 2 = z coordinate.
374 Returns:
375 true if successful.
376 */
377 bool SwapCoordinates(
378 int i,
379 int j
380 );
381
382 /*
383 Description:
384 Rotate a plane about its origin.
385 Parameters:
386 sin_angle - [in] sine of rotation angle
387 cos_angle - [in] cosine of rotation angle
388 axis - [in] axis of rotation
389 Returns:
390 true if successful
391 */
392 bool Rotate(
393 double sin_angle,
394 double cos_angle,
395 const ON_3dVector& axis
396 );
397
398 /*
399 Description:
400 Rotate a plane about its origin.
401 Parameters:
402 angle - [in] rotation angle in radians
403 axis - [in] axis of rotation
404 Returns:
405 true if successful
406 */
407 bool Rotate(
408 double angle,
409 const ON_3dVector& axis
410 );
411
412 /*
413 Description:
414 Rotate a plane about a point.
415 Parameters:
416 sin_angle - [in] sine of rotation angle
417 cos_angle - [in] cosine of rotation angle
418 axis - [in] axis of rotation
419 center - [in] center of rotation
420 Returns:
421 true if successful
422 */
423 bool Rotate(
424 double sin_angle,
425 double cos_angle,
426 const ON_3dVector& axis,
427 const ON_3dPoint& center
428 );
429
430 /*
431 Description:
432 Rotate a plane about a point.
433 Parameters:
434 angle - [in] rotation angle in radians
435 axis - [in] axis of rotation
436 center - [in] center of rotation
437 Returns:
438 true if successful
439 */
440 bool Rotate(
441 double angle,
442 const ON_3dVector& axis,
443 const ON_3dPoint& center
444 );
445
446 /*
447 Description:
448 Translate a plane.
449 Parameters:
450 delta - [in] translation vector
451 Returns:
452 true if successful
453 */
454 bool Translate(
455 const ON_3dVector& delta
456 );
457
458 /*
459 Description:
460 Flip plane orientation by swapping x and y axes,
461 reversing the zaxis, and updating the equation.
462 Returns:
463 true if successful
464 */
465 bool Flip();
466
467// world plane coordinate system ON_Plane(ON_origin, ON_xaxis, ON_yaxis);
468 const static
470
471public:
472 // origin of plane
474
475 // unit X axis of plane
477
478 // unit Y axis of plane
480
481 // unit Z axis of plane
483
484 // equation of plane
486 //double equation[4];
487};
488
490{
491public:
492 // C++ defaults for construction, destruction, copys, and operator=
493 // work fine.
494
498};
499
501{
502public:
505
506 void Default();
507
509 ON_UuidList m_viewport_ids; //ids of viewports that this clipping plane "clips"
511 bool m_bEnabled; // true if this clipping plane is active
512
513 ON_ClippingPlaneInfo ClippingPlaneInfo() const;
514
515 bool Read( class ON_BinaryArchive& );
516 bool Write( class ON_BinaryArchive& ) const;
517};
518
519
520#if defined(ON_DLL_TEMPLATE)
521
522// This stuff is here because of a limitation in the way Microsoft
523// handles templates and DLLs. See Microsoft's knowledge base
524// article ID Q168958 for details.
525#pragma warning( push )
526#pragma warning( disable : 4231 )
527ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_Plane>;
528ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_ClippingPlane>;
529ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_ClippingPlaneInfo>;
530#pragma warning( pop )
531
532#endif
533
537
538/*
539Description:
540 Get a convex hull of a set of 3d points.
541Parameters:
542 points - [in]
543 List of points. This function can handle tens of points
544 but is too slow for hundreds of points.
545 hull -[out]
546 Equations of the sides of the convex hull are appended to
547 this list.
548 A point P is inside the hull if hull[i].ValueAt(P) <= 0 for
549 every plane equation.
550Returns:
551 Number of equations appended to hull[] array.
552 If 0, then the points are coincident or colinear.
553 If 2, then the points are coplanar and the returned
554 planes are parallel.
555 If >= 4, then the points are in a 3d convex hull.
556*/
559 const ON_SimpleArray<ON_3dPoint> & points,
561 );
562
563#endif
@ Transform
Definition RSMetaType.h:67
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_array.h:760
Definition opennurbs_plane.h:501
ON_UUID m_plane_id
Definition opennurbs_plane.h:510
ON_Plane m_plane
Definition opennurbs_plane.h:508
bool m_bEnabled
Definition opennurbs_plane.h:511
ON_UuidList m_viewport_ids
Definition opennurbs_plane.h:509
Definition opennurbs_plane.h:490
bool m_bEnabled
Definition opennurbs_plane.h:497
ON_PlaneEquation m_plane_equation
Definition opennurbs_plane.h:495
ON_UUID m_plane_id
Definition opennurbs_plane.h:496
Definition opennurbs_line.h:20
Definition opennurbs_point.h:1169
Definition opennurbs_plane.h:20
ON_3dPoint origin
Definition opennurbs_plane.h:473
ON_3dVector xaxis
Definition opennurbs_plane.h:476
static const ON_Plane World_xy
Definition opennurbs_plane.h:469
ON_3dVector zaxis
Definition opennurbs_plane.h:482
ON_3dVector yaxis
Definition opennurbs_plane.h:479
ON_PlaneEquation plane_equation
Definition opennurbs_plane.h:485
Definition opennurbs_array.h:46
Definition opennurbs_xform.h:1146
Definition opennurbs_uuid.h:31
Definition opennurbs_array.h:1079
Definition opennurbs_xform.h:28
Rotates selected entities.
Definition Rotate.js:11
Translates (moves or copies) selected entities.
Definition Translate.js:11
void hull(void pointset, void concavity)
Definition hull.js:13
#define ON_DECL
Definition opennurbs_defines.h:92
#define ON_CLASS
Definition opennurbs_defines.h:91
#define ON_EXTERN_DECL
Definition opennurbs_defines.h:93
ON_DECL int ON_Get3dConvexHull(const ON_SimpleArray< ON_3dPoint > &points, ON_SimpleArray< ON_PlaneEquation > &hull)
Definition opennurbs_point.cpp:6591
ON_EXTERN_DECL const ON_Plane ON_xy_plane
ON_EXTERN_DECL const ON_Plane ON_yz_plane
ON_EXTERN_DECL const ON_Plane ON_zx_plane