dellipse3d.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
11 
19 struct GEOMDLLIMPEXP DEllipse3d
20 {
21 DPoint3d center;
22 DVec3d vector0;
23 DVec3d vector90;
24 double start;
25 double sweep;
26 
27 #ifdef __cplusplus
28 
29 
30 
31 //BEGIN_FROM_METHODS
49 static DEllipse3d From (double cx, double cy, double cz, double ux, double uy, double uz, double vx, double vy, double vz, double theta0, double sweep);
50 
52 static DEllipse3d FromCenterRadiusXY
53 (
54 DPoint3dCR center,
55 double radius
56 );
57 
63 static DEllipse3d FromFractionInterval
64 (
65 DEllipse3dCR parent,
66 double startFraction,
67 double endFraction
68 );
69 
85 static DEllipse3d FromXYMajorMinor (double cx, double cy, double cz, double rx, double ry, double thetaX, double theta0, double sweep);
86 
98 static DEllipse3d FromPoints (DPoint3dCR center, DPoint3dCR point0, DPoint3dCR point90, double theta0, double sweep);
99 
101 static ValidatedDEllipse3d FromStartTangentNormalRadiusSweep (
102 DPoint3dCR pointA,
103 DVec3dCR tangent,
104 DVec3dCR planeNormal,
105 double radius,
106 double sweepRadians
107 );
116 static DEllipse3d FromPointsOnArc (DPoint3dCR start, DPoint3dCR middle, DPoint3dCR end);
117 
124 static DEllipse3d FromArcCenterStartEnd (DPoint3dCR center, DPoint3dCR startPoint, DPoint3dCR endTarget);
125 
127 static DEllipse3d FromVectors
128 (
129 DPoint3dCR center,
130 DVec3dCR vector0,
131 DVec3dCR vector90,
132 double theta0,
133 double sweep
134 );
135 
137 static DEllipse3d FromScaledRotMatrix
138 (
139 DPoint3dCR center,
140 RotMatrixCR matrix,
141 double r0,
142 double r90,
143 double theta0,
144 double sweep
145 );
147 static DEllipse3d FromScaledVectors
148 (
149 DPoint3dCR center,
150 DVec3dCR vector0,
151 DVec3dCR vector90,
152 double r0,
153 double r90,
154 double theta0,
155 double sweep
156 );
157 
159 static DEllipse3d FromScaledVectors
160 (
161 DEllipse3dCR source,
162 double factor
163 );
164 
165 
169 static DEllipse3d FromMajorMinor (DEllipse3dCR source);
170 
175 static DEllipse3d FromCenterNormalRadius (DPoint3dCR center, DVec3dCR normal, double radius);
176 
181 static DEllipse3d FromPerpendicularAxes (DEllipse3dCR source);
184 static DEllipse3d FromReversed (DEllipse3dCR source);
185 
188 DEllipse3d FromNegateVector90 (DEllipse3dCR source);
189 
190 
197 static DEllipse3d FromCopyWithPositiveSweep (DEllipse3dCR source);
198 
199 
204 static DEllipse3d FromRotatedAxes (DEllipse3dCR source, double newStart);
205 //END_FROM_METHODS
206 
223 void Init
224 (
225 double cx,
226 double cy,
227 double cz,
228 double ux,
229 double uy,
230 double uz,
231 double vx,
232 double vy,
233 double vz,
234 double theta0,
235 double sweep
236 );
237 
252 void InitFromXYMajorMinor
253 (
254 double cx,
255 double cy,
256 double cz,
257 double rx,
258 double ry,
259 double thetaX,
260 double theta0,
261 double sweep
262 );
263 
274 void InitFromPoints
275 (
276 DPoint3dCR center,
277 DPoint3dCR point0,
278 DPoint3dCR point90,
279 double theta0,
280 double sweep
281 );
282 
292 bool InitFromPointsOnArc
293 (
294 DPoint3dCR start,
295 DPoint3dCR middle,
297 );
298 
314 bool InitArcFromPointPointArcLength
315 (
316 DPoint3dCR startIN,
318 double arcLength,
319 DVec3dCR planeVector
320 );
321 
331 bool InitArcFromPointTangentPoint
332 (
333 DPoint3dCR startIN,
334 DVec3d tangent,
336 );
337 
351 bool InitFromArcCenterStartEnd
352 (
353 DPoint3dCR centerIN,
354 DPoint3dCR startIN,
356 );
357 
368 void InitFromVectors
369 (
370 DPoint3dCR centerIN,
371 DVec3dCR vector0IN,
372 DVec3dCR vector90IN,
373 double theta0,
374 double sweepIN
375 );
376 
377 
395 bool SetStartEnd
396 (
397 DPoint3dCR startPoint,
398 DPoint3dCR endPoint,
399 bool ccw
400 );
401 
414 void InitFromScaledRotMatrix
415 (
416 DPoint3dCR centerIN,
417 RotMatrixCR matrix,
418 double r0,
419 double r1,
420 double theta0,
421 double sweepIN
422 );
423 
424 
425 
438 void InitFromScaledVectors
439 (
440 DPoint3dCR centerIN,
441 DVec3dCR vector0IN,
442 DVec3dCR vector90IN,
443 double r0,
444 double r1,
445 double theta0,
446 double sweepIN
447 );
448 
453 void InitMajorMinor
454 (
455 DEllipse3dCR source
456 );
457 
469 void GetScaledRotMatrix
470 (
471 DPoint3dR center,
472 RotMatrixR matrix,
473 double &r0,
474 double &r1,
475 double &theta0,
476 double &sweep
477 ) const;
478 
479 
491 void GetScaledTransforms
492 (
493 TransformR localToWorld,
494 double &r0,
495 double &r1,
496 double &theta0,
497 double &sweep,
498 TransformR worldToLocal
499 ) const;
507 void InitFromCenterNormalRadius
508 (
509 DPoint3dCR centerIN,
510 DVec3dCR normal,
511 double radius
512 );
513 
519 bool IsFullEllipse () const;
520 
523 bool IsNearZeroRadius() const;
524 
526 bool IsAlmostEqual (DEllipse3dCR other, double tolerance) const;
532 void MakeFullSweep ();
533 
539 void ComplementSweep ();
540 
541 
543 DPoint3d RadiansToPoint (double theta) const;
551 void Evaluate
552 (
553 DPoint3dR point,
554 double xx,
555 double yy
556 ) const;
557 
564 void Evaluate
565 (
566 DPoint4dR point,
567 double theta
568 ) const;
569 
576 void EvaluateEndPoints
577 (
578 DPoint3dR startPoint,
579 DPoint3dR endPoint
580 ) const;
581 
590 void Evaluate
591 (
592 DPoint3dR point3dX,
593 DVec3dR dX,
594 DVec3dR ddX,
595 double theta
596 ) const;
597 
604 void FractionParameterToPoint
605 (
606 DPoint3dR point3dX,
607 double fraction
608 ) const;
609 
611 DPoint3d FractionToPoint (double fraction) const;
612 
621 void FractionParameterToDerivatives
622 (
623 DPoint3dR point3dX,
624 DVec3dR dX,
625 DVec3dR ddX,
626 double fraction
627 ) const;
628 
636 void Evaluate
637 (
638 DPoint3dP point3dX,
639 int numDerivative,
640 double theta
641 ) const;
642 
649 double FractionToAngle (double fraction) const;
650 
656 double DeterminantJXY () const;
657 
666 bool GetLocalFrame
667 (
668 TransformR frame,
669 TransformR inverse
670 ) const;
671 
679 bool GetXYLocalFrame
680 (
681 TransformR frame,
682 TransformR inverse
683 ) const;
684 
685 
698 bool PointToXYLocal
699 (
700 DPoint3dR localPoint,
701 DPoint3dCR point
702 ) const;
703 
711 double PointToAngle (DPoint3dCR point) const;
712 
723 bool ProjectPointToPlane
724 (
725 DPoint3dR xYZNear,
726 double &coff0,
727 double &coff90,
728 DPoint3dCR xYZ
729 ) const;
730 
740 int GetStrokeCount
741 (
742 int nDefault = 12,
743 int nMax = 180,
744 double chordTol = 0.0,
745 double angleTol = 0.0
746 ) const;
747 
756 void EvaluateTrigPairs
757 (
758 DPoint3dP point,
759 DPoint2dCP trig,
760 int numPoint
761 ) const;
762 
773 int TestAndEvaluateTrigPairs
774 (
775 DPoint3dP point,
776 DPoint2dCP trig,
777 int numPoint
778 ) const;
779 
786 bool IsAngleInSweep (double angle) const;
787 
794 double AngleToFraction (double angle) const;
795 
802 void GetLimits
803 (
804 double &startAngle,
805 double &endAngle
806 ) const;
807 
814 void GetSweep
815 (
816 double &startAngle,
817 double &sweepAngle
818 ) const;
819 
826 void SetLimits
827 (
828 double startAngle,
829 double endAngle
830 );
831 
838 void SetSweep
839 (
840 double startAngle,
841 double sweepIN
842 );
843 
851 void InitWithPerpendicularAxes (DEllipse3dCR source);
852 
867 double GetMajorMinorRangeMidlines
868 (
869 DSegment3dR longSegment,
870 DSegment3dR shortSegment
871 ) const;
872 
879 void InitReversed (DEllipse3dCR source);
880 
887 double TangentMagnitude (double theta) const;
888 
894 double ArcLength () const;
895 
903 double InverseArcLength (double arcLength) const;
904 
914 bool FractionToLength
915 (
916 double &arcLength,
917 double fraction0,
918 double fraction1
919 ) const;
920 
926 void GetRange (DRange3dR range) const;
927 
934 void GetLocalRange (DRange2dR range) const;
935 
936 
939 DRange1d ProjectedParameterRange (DRay3dCR ray) const;
940 
956 int IntersectPlane
957 (
958 DPoint3dP trigPoints,
959 DPoint4dCR plane
960 ) const;
961 
967 int SolveTangentsPerpendicularToVector
968 (
969 double *angles,
970 DVec3dR vector
971 ) const;
987 int IntersectXYLine
988 (
989 DPoint3dP cartesianPoints,
990 double *pLineParams,
991 DPoint3dP ellipseCoffs,
992 double *pEllipseAngle,
993 DPoint3dCR startPoint,
994 DPoint3dCR endPoint
995 ) const;
996 
1000 bool IsCircular () const;
1001 
1005 bool IsCircular (double &radius) const;
1006 
1009 bool IsCircularXY () const;
1010 
1013 bool IsCircularXY (double &radius) const;
1014 
1018 bool IsCCWSweepXY () const;
1019 
1036 int IntersectXYDEllipse3d
1037 (
1038 DPoint3dP cartesianPoints,
1039 DPoint3dP ellipse0Params,
1040 DPoint3dP ellipse1Params,
1041 DEllipse3dCR ellipse1
1042 ) const;
1043 
1062 int IntersectXYDEllipse3dBounded
1063 (
1064 DPoint3dP cartesianPoints,
1065 DPoint3dP ellipse0Coffs,
1066 double *pEllipse0Angle,
1067 DPoint3dP ellipse1Coffs,
1068 double *pEllipse1Angle,
1069 DEllipse3dCR ellipse1
1070 ) const;
1071 
1093 int IntersectSweptDEllipse3d
1094 (
1095 DPoint3dP cartesianPoints,
1096 DPoint3dP ellipse0Params,
1097 DPoint3dP ellipse1Params,
1098 DEllipse3dCR ellipse1
1099 ) const;
1100 
1120 int IntersectSweptDEllipse3dBounded
1121 (
1122 DPoint3dP cartesianPoints,
1123 DPoint3dP ellipse0Coffs,
1124 double *pEllipse0Angle,
1125 DPoint3dP ellipse1Coffs,
1126 double *pEllipse1Angle,
1127 DEllipse3dCR ellipse1
1128 ) const;
1129 
1147 int IntersectSweptDSegment3d
1148 (
1149 DPoint3dP pointArray,
1150 DPoint3dP ellipseParams,
1151 double *pLineParams,
1152 DSegment3dCR segment
1153 ) const;
1154 
1169 int IntersectSweptDSegment3dBounded
1170 (
1171 DPoint3dP pointArray,
1172 DPoint3dP ellipseParams,
1173 double *pLineParams,
1174 DSegment3dCR segment
1175 ) const;
1176 
1186 int ProjectPoint
1187 (
1188 DPoint3dP cartesianPoints,
1189 double *pEllipseAngle,
1190 DPoint3dCR point
1191 ) const;
1192 
1202 int ProjectPointXY
1203 (
1204 DPoint3dP cartesianPoints,
1205 double *pEllipseAngle,
1206 DPoint3dCR point
1207 ) const;
1208 
1218 int ProjectPointXYBounded
1219 (
1220 DPoint3dP cartesianPoints,
1221 double *pEllipseAngle,
1222 DPoint3dCR point
1223 ) const;
1224 
1234 int ProjectPointBounded
1235 (
1236 DPoint3dP cartesianPoints,
1237 double *pEllipseAngle,
1238 DPoint3dCR point
1239 ) const;
1240 
1251 bool ClosestPointXYBounded
1252 (
1253 double &minAngle,
1254 double &minDistanceSquared,
1255 DPoint3dR minPoint,
1256 DPoint3dCR point
1257 ) const;
1258 
1269 bool ClosestPointBounded
1270 (
1271 double &minAngle,
1272 double &minDistanceSquared,
1273 DPoint3dR minPoint,
1274 DPoint3dCR point
1275 ) const;
1276 
1291 int IntersectXYLineBounded
1292 (
1293 DPoint3dP cartesianPoints,
1294 double *pLineParams,
1295 DPoint3dP ellipseCoffs,
1296 double *pEllipseAngle,
1297 bool *pIsTangency,
1298 DPoint3dCR startPoint,
1299 DPoint3dCR endPoint
1300 ) const;
1301 
1309 void XySweepProperties
1310 (
1311 double &area,
1312 double &sweepOUT,
1313 DPoint3dCR point
1314 ) const;
1315 
1336 void QuadricBezierPoles
1337 (
1338 DPoint4dP poleArray,
1339 DPoint3dP circlePoleArray,
1340 double *angleArray,
1341 int *pNumPole,
1342 int *pNumSpan,
1343 int maxPole
1344 ) const;
1345 
1346 
1347 void QuadricBezierPoles
1348 (
1349 DPoint4dP poleArray,
1350 DPoint3dP circlePoleArray,
1351 int *pNumPole,
1352 int *pNumSpan,
1353 int maxPole
1354 ) const;
1355 
1356 
1357 
1369 bool InitFromCenterMajorAxisPointAndThirdPoint
1370 (
1371 DPoint3dCR centerIN,
1372 DPoint3dCR point0,
1373 DPoint3dCR point1
1374 );
1375 
1387 int ClosestApproach
1388 (
1389 double *pEllipseAngleBuffer,
1390 double *pRayFractionBuffer,
1391 DPoint3dP ellipsePointBuffer,
1392 DPoint3dP rayPointBuffer,
1393 DRay3dCR ray
1394 ) const;
1395 
1409 void InitFromDGNFields3d
1410 (
1411 DPoint3dCR centerIN,
1412 DVec3dCR directionX,
1413 DVec3dCR directionY,
1414 double rX,
1415 double rY,
1416 double startAngle,
1417 double sweepAngle
1418 );
1429 void InitFromDGNFields3d
1430 (
1431 DPoint3dCR centerIN,
1432 double const* pQuatWXYZ,
1433 double rX,
1434 double rY,
1435 double startAngle,
1436 double sweepAngle
1437 );
1449 void InitFromDGNFields2d
1450 (
1451 
1452 DPoint2dCR centerIN,
1453 DVec2dCR direction0,
1454 double rX,
1455 double rY,
1456 double startAngle,
1457 double sweepAngle,
1458 double zDepth
1459 
1460 );
1472 void InitFromDGNFields2d
1473 (
1474 DPoint2dCR centerIN,
1475 double xAngle,
1476 double rX,
1477 double rY,
1478 double startAngle,
1479 double sweepAngle,
1480 double zDepth
1481 
1482 );
1483 
1499 void GetDGNFields3d
1500 (
1501 DPoint3dR centerOUT,
1502 double * pQuatWXYZ,
1503 DVec3dR directionX,
1504 DVec3dR directionY,
1505 double &rx,
1506 double &ry,
1507 double &startAngle,
1508 double &sweepAngle
1509 ) const;
1510 
1514 void GetDGNFields2d
1515 (
1516 DPoint2dR centerIN,
1517 double &xAngle,
1518 DVec2dR direction0,
1519 double &rx,
1520 double &ry,
1521 double &startAngle,
1522 double &sweepAngle
1523 ) const;
1524 
1531 bool AlignedRange
1532 (
1533 TransformR localToGlobal,
1534 TransformR globalToLocal,
1535 DRange3dR range
1536 ) const;
1537 
1541 double MaxAbs () const;
1542 
1549 bool ClosestPointBoundedXY
1550 (
1551 DPoint3dR closePoint,
1552 double& closeParam,
1553 double& distanceXY,
1554 DPoint3dCR spacePoint,
1555 DMatrix4dCP worldToLocal
1556 ) const;
1557 
1566 bool ClosestPointBoundedXY
1567 (
1568 DPoint3dR closePoint,
1569 double& closeParam,
1570 double& distanceXY,
1571 DPoint3dCR spacePoint,
1572 DMatrix4dCP worldToLocal,
1573 bool extend0,
1574 bool extend1
1575 ) const;
1576 
1577 
1578 
1585 void WireCentroid
1586 (
1587 double &length,
1588 DPoint3dR centroid,
1589 double fraction0 = 0.0,
1590 double fraction1 = 1.0
1591 ) const;
1592 
1600 static void Construct_XRadius_YRadius_XPoint_EdgePoint
1601 (
1602 bvector<DEllipse3d>&ellipses,
1603 double a,
1604 double b,
1605 DPoint3dCR xPoint,
1606 DPoint3dCR edgePoint
1607 );
1608 
1616 static void Construct_XPoint_EdgePoint_EdgePoint_XRadius (
1617 bvector<DEllipse3d> &ellipses,
1618 DPoint3dCR xPoint,
1619 DPoint3dCR edgePoint0,
1620 DPoint3dCR edgePoint1,
1621 double a
1622 );
1623 
1624 
1625 
1632 static bool TryConstruct_EdgePoint_XPoint_EdgePoint_XAngle
1633 (
1634 DEllipse3dR ellipse,
1635 DPoint3dCR edgePoint0,
1636 DPoint3dCR xPoint,
1637 DPoint3dCR edgePoint1,
1638 double xAngle
1639 );
1640 
1647 static void Construct_Point_Direction_TangentXY
1648 (
1649 bvector<DEllipse3d> &ellipse,
1650 bvector<double> &fractionB,
1651 DPoint3dCR pointA,
1652 DVec3dCR directionA,
1653 DRay3d rayB
1654 );
1655 
1656 #endif
1657 
1658 };
Center, reference vectors, and angular range for elliptic arc.
Definition: dellipse3d.h:19
struct RotMatrix & RotMatrixR
Definition: msgeomstructs_typedefs.h:135
struct DPoint4d & DPoint4dR
Definition: msgeomstructs_typedefs.h:96
struct DVec2d const & DVec2dCR
Definition: msgeomstructs_typedefs.h:90
struct DPoint4d * DPoint4dP
Definition: msgeomstructs_typedefs.h:96
DVec3d vector0
Vector from center to parametric 0-degree point.
Definition: dellipse3d.h:22
DVec3d vector90
Vector from center to parametric 90-degree point.
Definition: dellipse3d.h:23
struct DVec3d & DVec3dR
Definition: msgeomstructs_typedefs.h:89
#define END_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:30
iterator end()
Definition: stdcxx/bstdmap.h:186
DPoint3d center
Center of ellipse.
Definition: dellipse3d.h:21
struct RotMatrix const & RotMatrixCR
Definition: msgeomstructs_typedefs.h:135
struct Transform & TransformR
Definition: msgeomstructs_typedefs.h:134
struct DPoint2d & DPoint2dR
Definition: msgeomstructs_typedefs.h:78
struct DPoint3d * DPoint3dP
Definition: msgeomstructs_typedefs.h:79
struct DRange2d & DRange2dR
Definition: msgeomstructs_typedefs.h:110
struct DSegment3d & DSegment3dR
Definition: msgeomstructs_typedefs.h:115
struct DEllipse3d & DEllipse3dR
Definition: msgeomstructs_typedefs.h:114
struct DRange3d & DRange3dR
Definition: msgeomstructs_typedefs.h:108
double sweep
Sweep angle in parameterization.
Definition: dellipse3d.h:25
struct DPoint2d const & DPoint2dCR
Definition: msgeomstructs_typedefs.h:78
A Bentley supplied implementation std::vector.
Definition: stdcxx/bvector.h:77
struct DVec2d & DVec2dR
Definition: msgeomstructs_typedefs.h:90
struct DPoint3d & DPoint3dR
Definition: msgeomstructs_typedefs.h:79
Start point and direction (NOT necessarily unit) for a 3D ray.
Definition: dray3d.h:21
struct DSegment3d const & DSegment3dCR
Definition: msgeomstructs_typedefs.h:115
A 1d interval with low and high values.
Definition: DRange1d.h:41
struct DMatrix4d const * DMatrix4dCP
Definition: msgeomstructs_typedefs.h:97
double start
Start angle in parameterization.
Definition: dellipse3d.h:24
ValidatedValue< DEllipse3d > ValidatedDEllipse3d
Definition: GeomApi.h:359
struct DEllipse3d const & DEllipse3dCR
Definition: msgeomstructs_typedefs.h:114
#define BEGIN_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:29
struct DPoint3d const & DPoint3dCR
Definition: msgeomstructs_typedefs.h:79
struct DRay3d const & DRay3dCR
Definition: msgeomstructs_typedefs.h:120
struct DVec3d const & DVec3dCR
Definition: msgeomstructs_typedefs.h:89
struct DPoint2d const * DPoint2dCP
Definition: msgeomstructs_typedefs.h:78
struct DPoint4d const & DPoint4dCR
Definition: msgeomstructs_typedefs.h:96

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.