Perfect 3D-curve RMDPL-IPOs & Bresenham’s 3D-Curve Algorithm (Part 2 & 3)

The paper presents three new 26-connected constant feedrate incremental step algorithms that can be used in practical situations in CNC machining tools. The 1 st , the perfect 3D line IPO is 100% incremental, the word "perfect" means that the accuracy can be much better than the accuracy of Bresenham's 3D line (e.g. accuracy can be 37% worse) The simplified state diagram computes one perfect major axis points and possibly a perfect non-major axis point. The selection criterion uses the real 3D distance to the line. The 2 nd , the perfect 3D curve IPO is a QSIC-algorithm (intersection of two quadrics). The selection criterion uses the "Relative Curve Measurement Theorem" extended to quadrics and QSICs. The consequences of this theorem are crucial, it means that one must not calculate the time-consuming distance to the 3D curve, but it suffices to calculate the RMDPL or the relative minimal distance of two candidate points to the polar line of the QSIC with respect to the midpoint of the candidate points. As the midpoints are close to the curve, the polar lines enclose and inclose the curve . Theoretical, the RMDPL is fundamental, it is the core of all the successful 2D incremental step algorithms and the paper proves that it is the core of the 3D incremental step algorithms or the 3D reference pulse IPOs. Thanks to the RMDPL, the paper represents QSICs in a unique way comparable with 3D-lines. The 3 rd , Bresenham's imperfect 3D curve IPO super-fast used many practical as the maximum error (MaxErr) is bounded to . The All the and the are precomputed as the intersection points of three quadrics.


1.
Introduction and overview

Introduction to the intersection curve of two quadrics (QSIC)
According to [7, § 4.1.2., Table 5], "Among all categories, the "Process System" category and "Numerical Control System" category contains the largest number of research concerns, accounting for 34.8% and 19.0% of the total research concerns respectively. According to domain knowledge, these two categories are the focuses of the research in the machine tool domain". This paper is the sequel of [1;4] and belongs to the "Process System" category with the topics indexes 47 and 85 (interpolation), but with the indexes 10, 16,22,63,83,121,125,128,136, the paper belongs to the category "Numerical Control system", too. The meaning of the topics and the highfrequent terms of the topics are given in [7, Appendix A, Table A1]. Although in 1981, Koren used the term "reference pulse circle interpolator, the term is not found in [7]. It has always been a problem to find the right term for these interpolators, which are in fact incremental algorithms (but the term incremental is also not found in [7]). Computer graphics and displays also apply the reference pulse algorithms, but they do not use the name "IPOs", but they call it raster graphics or scan-conversion. The most known are the Bresenham algorithms, the two-point method, the griddistance method, and the midpoint algorithm. Part 1 of [1 ; 4] showed that the reference-pulse IPOs have high accuracy, constant feedrate and that high-speed machining can be obtained without using a high-performance CPU. The paper considered 2D-lines, imperfect 3D-lines, conic-curves and 2D-NURBS. The paper also proved that the constant feedrate reference IPOs are much better than the existing sampled-data IPOs: the constant feedrate is better, the accuracy is better, the incremental step algorithms calculate the length (npuls) of the curve in real time and the implementation is simpler. This paper combines part 2, the perfect 3D-line IPO and part 3, the perfect 3D-QSIC IPO, because these IPOs are based on the same concept and equations ( § 2).
The number of papers about QSICs is large [16 -29]: Morphology and classification of the QSICs, literature for computing QSICs using the geometric approach for mostly natural quadrics and the algebraic approach producing a (rational) parameterization of the QSIC, tracing QSICs using mostly step marching and some limited cases with interpolation, finding a point of the QSIC, solving the undefined direction in singular points. Determining the nonzero direction vector in a singular point has been solved by [21, pp. 24], [22, pp. 179], and requires the solution of the characteristic equation [22,Sec. 8.4], [23, pp. 295 Fig. 3.1], [24, pp. 113, example 6.2]. The singular point is an extreme point, and it is only a tracing problem when the curve starts in the singular point Ps (no direction); a very practical and simple solution is given ( § 2.6). The QSIC of the quadrics f1[P]=0 and f2[P]=0 is identical with the QSIC of one of the quadrics and its pencil, but for machining, one of the quadrics cannot be replaced with a pencil quadric because the geometric surfaces of quadrics are important. The 3D-line is the intersection of two planes or the intersection of two orthogonal planes This paper gives not an overview of the existing tracing methods, because the paper represents the QSIC in a unique way as the vector function [ (14) and [ DGtal 1.2 can also generate 26-connected curves from 3D parametric curves. DGtal gives no constant feedrate curves, and the tool has connectivity problems when the curvature is high and with large step values. To our knowledge, we found no papers using step interpolation of QSICs or reference pulse interpolation of QSICs with constant feedrate. Recently, [10] adds a fifth imperfect 3D-line IPO to the imperfect-3D-line IPOs of [1; 4, §3.2], it argues to be better than [8], because the "discriminant contains decimals". That is completely wrong, because the four referenced IPOs [1; 4, §3.2] are basic integer arithmetic algorithms, although most of them can be used with floating point arithmetic too. The algorithm [10,Fig. 5] is much slower than the 3D-PRM-IPO of [1;4, § 3.2, Item 3 ]. Paper [15] references [31], a book of 2008. The authors of [15], seemingly, do not want to correct their false statement; therefore we repeat the false statement of [15,II Related Work] : "In the first group mentioned (the Reference-Pulse Interpolators), a computer generates reference pulses as an external interrupt signal. The produced pulses are relegated directly to the machine drive. It can achieve high accuracy but as the velocity on each axis depends on external interrupt signal frequency, high speed machining cannot be obtained, and a high-performance Central Processing Unit (CPU) is required". The 2 nd group are the "Reference-Word Interpolators" which belong to the sampled-data IPOs and [1 ; 4] proved that the reference pulse interpolators are faster, simpler, have much better accuracy and constant feedrate than the sampled-data interpolators. The low cost PIC32 of Microchip is outstanding suitable to realize a real time 3D-curve CNC controller with constant feedrate. The 3D-algorithms of this paper, called incremental step IPOs or shortly IPOs are unique (new concept), fast and simple. The curve is always divided into monotonic sub curves with the use of the offline-calculated extreme points ( § 2.6). The paper assumes that [2] and especially the "Relative Curve Measurement Theorem" [2, §5] can be extended to quadrics and QSICs (all experiments show that it can). The consequences of this theorem are not well understood, it means that one must not calculate the time-consuming distance to the 3D-curve for each of the seven candidate points (Fig.1), but it suffices to calculate the Relative Minimal Distance of two candidate points to the Polar Line of the QSIC with respect to the midpoint of the candidate points ("RMDPL") ( §2.2; §2.5). The word "polar" induces equations in "polar coordinates", but it has nothing to do with polar coordinates.  (33). As seen from (40;33), d[Pu,Pv] uses the gradient of the midpoint of the two candidate points, therefore it is very flexible, and it allows to calculate the problematic curvatures in real time.
The LSD algorithms are virtual because they consume too much time, the RMDPL algorithms are amazingly fast and for lines the RMDPL's are precomputed constants ( § 3, 76; 77; 78; 79). When you analyses the 2D-Bresenham's and its corresponding midpoints algorithms [13;14;30]], they all can be replaced with RMDPL-algorithms (Appendix 7.1). It seems that the core of the MIDP-algorithm is not well understood, therefore the following simple 2D-clarification of [2]. In 2D, e.g. for the points P1, P2, P3 (Fig. 1) The crux of [2, § 5] is the relative curve measurement theorem that says that the difference of the squared distances to the conic equals 2 When the midpoint measurement is not OoC then When the midpoint measurement is not OoA then H OoA can occur when Pm is INSIDE and extremely near to the conic [2, § 7]. This means that the RMDPL or the difference of the squared distances to a quadratic curve can be measured by replacing the curve by its polar line, and the rarely OoA-error is smaller than { 0.5, √ /2 } for respectively 2D-or 3D-curves. The RMDPL will be applied to the perfect 3D-line ( §3) and to the perfect 3D-QSIC ( the polar lines of the intersection curve of two quadrics) ( § 4). The RMDPL will also be applied to the imperfect 3D-QSIC, and as a tribute to J. Bresenham it is called the "Bresenham's 3D-curve algorithm" ( § 5). You can regard it as an extension of Bresenham's 3D-line algorithm using the intersection of the two polar planes, called the "QSIC polar line". Bresenham's 3D-curve algorithm is a major axis algorithm, and it measures two projected distances instead of the real 3D-distance, therefore the accuracy (MaxErr, Cost) is not minimal. . For 3D-lines, in contrast with 3D-curves, L equals PE -PS .
A line has a gradient perpendicular to the line. A 2D-line has one gradient, and a 3D-line has two gradients which define two planes, and the 3D-line is the intersection of the two planes. The line can be defined in two ways. T P W P PP T P T P (23).
Hence, the QSIC may be written, analogous with the 3D-line, as  , are not directly given, but must be calculated giving the gradients and the two (degenerated) quadrics.
The perfect 3D-line algorithm or the best 3D-line IPO ( § 3) will use the first form, because [ ] [ ] =  + f P L P W P (22) are linear equations of P and the precalculated coefficients are constants. The best RMDPL point of the seven candidate points (Fig. 1) is found by pairwise comparing two candidate points and the perfect 3D-line IPO needs 21 decision variables. Each decision variable is a linear equation with constant coefficients, hence that IPO needs no multiplications, but only additions / subtractions and comparisons with zero. Paragraphs §2.6 and §2.8 show that one can only apply the constant feedrate algorithm, when a major axis move occurs. Selecting the best point of the seven candidate points is not sufficient to find the discrete curve with the minimum MaxErr and the minimum Cost, but the state diagram ( §2.8) gives the solution.
The IPO of the QSIC, e.g. the intersection of a sphere and a cylinder will use the second form. This form can be used for the IPO of the perfect 3D-curve or the perfect 26-connected QSIC. The VIRT-IPO (30)(31) uses the LSD method [1, §4.4] to compute the parameters MaxErr and Cost. The PS of the equivalent first form always changes and that is the reason that the algorithm of a QSIC cannot be incremental for 100%. In addition to the perfect 3D-curve IPO, this paper gives the fast imperfect Bresenham's 3D-curve IPO ( § 5).

2.
The QSIC and its polar line equation and the relative decision function

The QSIC equation in vector form
For each index r = {1,2}, the quadric fr[P] is a quadric of the 2 nd degree with rational coefficients   (2) The equations of the intersections of the two quadrics become, The sign parameter SL is unique defined from the primary OoC condition (2) and the gradients (6) in the startpoint Ps (10).. Multiplying respectively f1 with SLG2, f2 with SLG1 and subtracting gives, after applying the (17) The equation of the QSIC is the complex vector function (15). The scalar components are cubics in {x,y,z} and the solution in implicit form is unknown.
Many terms are quadrics, and to update these terms you can use (16) and the 2D-update [5, Item d. Upd] and the extended 3D-update ( § 5.3). In order that the paper will remain clear, the equations will be written in clear form and not in incremental form.
The relative curve measurement theorem extended to QSICs, assumes that So, we do not compute the relative squared distances to a QSIC, but we compute the relative squared distances of two candidate points ( § 2.4) of the polar line of the QSIC with respect to the midpoint Pm of the two candidate points {P1, P2} ( § 2.2).

The polar line of the QSIC
The polar of a quadric becomes a polar plane. The polar planes of the quadrics (5) with respect to the point Pm become, Multiplying respectively L1 and subtracting gives, after applying the identity (15) the intersection of the polar planes, =  + = f P T P P W P (22) The equation of the polar line of the QSIC is the vector function (22). The scalar components are linear in {x,y,z}. The next section computes the squared distance to the line (22).

The squared distance of a point Pn to the polar line of the QSIC with respect to Pm
There always exists a point Sm The virtual startpoint Ps depends on the midpoint Pm and the virtual polar line becomes To simplify the equations, we put mm [] Version 1: Monday, July 19, 2021 P a g e | 10 The distance vector from a point n P to the polar line L [] fP =0 equals after applying the identity Applying the identity 1 m This function cannot be used to compute the maximal error MaxErr of the discrete QSIC or to compute the best point of the candidate points, but the time-consuming "RegionDistance" can be used. All the IPOs in the paper compute the discrete points Pn using the RMDPL criterion (33 -34; §2.5), and with these points the real distance dErr[Pn] is calculated and finally MaxErr and the Cost.

Measuring the absolute error or distance to a QSIC using the virtual LSD
• Put 11

2.4
The sign of the relative decision function When the priority of point Pu is higher or equal than the priority of point Pv the RMDPL criterion selects Pu when Hence, the best pairwise selection criterion is: Using (29) and (34) the relative decision function becomes  PP , the practical decision function is The form (40) of the decision variable will be used in this paper.
. But it is difficult to transform it to a scalar form, therefore we reformat the equations (20) and (22) respectively as (20) u ] 0 22 The vector equation (43) cannot be used with the current scalar arithmetic, but using and working out (43) gives the relative 3D decision function in function of the defining quadrics and its gradients,    P P P P P P P P P P P P G P P P P P P P P P P P P G P P P P P P This can be written in simple scalar form as In 2D 2m  Gk , 1m 2m 0  GG and f2 is zero or a constant, hence the 2D decision function becomes the well-known midpoint decision function

The Simplified State Diagram
To clearly define the wrong 26-connected paths we take segments of the imperfect 3D-line of [1;4, § 3.2.2.1 & Table 4]. • the main axis index majN ≡ 3 corresponding with the major axis direction in the startpoint PA, • the three successive LSD points PA1, PA2 and PA3 , • the Boolean b02 is true when PA2 is 26-connected with PA, • the Boolean b13 is true when PA3 is 26-connected with PA1, • the Boolean bmajAi is true when the move to PAi is major axis move majN. • dErr is the absolute error or distance to a QSIC using the virtual LSD (31)   Therefore the selected paths are as in Table 4. The non-major axis rule: "Two successive non-major axis moves are impossible". The proper IPO can apply the general state diagram, but the IPO only applies the PRM-cs (feedrate) for each major axis move ( § 2.8). When PA1 is a major axis move (bmajA1=True) the IPO can be restarted, else when PA1 is a non-major axis move (bmajA1=False), the non-major axis rule says that the next best point is a major axis move (bmajA2≡True), and the IPO can then be restarted.
The simplified state diagram applies the non-major axis rule "Two successive non-major axis moves are impossible". LSD point PA3 must not be calculated and b13 is always false. The simplified state diagram becomes (Table 5): All perfect IPOs in this paper will use the simplified state diagram.
The 3D-polar line (22)    The PRM-cs is not an integer algorithm when LM uses (63). The PRM-cs is an integer algorithm when LM uses (64). Conclusions of § 2.8: • You can only run the PRM-cs algorithm when the 3D-curve makes a major axis move, • The length of the vector TA must be normalized to obtain the correct feedrate, • The PRM-cs algorithm can use integer arithmetic.   The examples are subdivided into three groups : the Virtual IPO (30-32), the RMDPL-IPO ( § 3; § 4) and the Bresenham's 3D-curve-IPO ( § 5). The maximal error MaxErr is only once computed and copied to MaxErr when dErr is not computed.     The perfect 3D-line IPO

Introduction to the examples
The perfect 3D-line IPO, in CDF-form, can be found in [35].
The equation of the QSIC (17) The startpoint Ps has only influence on the initial conditions, and as the line is linear, the startpoint can be zero.

Some details of the perfect 3D-line IPO and its incremental updates:
To  The perfect RMDPL 3D-curve IPO The perfect 3D-curve IPO, without updates in CDF-form, can be found in [36].

Online calculations of RMDPL algorithms (While loop)
The practical decision function of the RMDPL-IPO is (40), with (50) and uv m 2  −  + P P P P P P P P P P T P P T W The two terms of the dot product of (40) are GG 's were quadrics and were incremental computed (18). The paper was never published, because it is impossible to publish it in a clear way, but the execution time was acceptable and some results for 6-and 26-connected QSICS are given (Appendix 7.2, Table 12). The object of the paper is to represent the 3D IPOs as clearly as possible, therefore the while loops of the RMDPL-IPO and Bresenham' 3D-IPO will not be presented in incremental form. Recompute Sδ={δx, δy, δz} (96) before starting the While-loop.

While loop of the RMDPL-IPO:
The while loop starts with the current best point PA and set b02=bmajA1=bmajA2=False. • PA to PA1 is a non-major axis move, and PA1 to PA2 is a major axis move.

Bresenham's 3D-curve IPO
Bresenham's 3D-curve IPO, without updates in CDF-form, can be found in [37]. Bresenham's 3D algorithm is imperfect because 1. Each move is a major-axis move, but that simplifies the constant feedrate calculation, and instead of 21 decision variables, only 2 decision variables per major-axis direction are needed, therefore its speed is significant higher; 2. The decision function is simpler but does not measure the 3D distance to the polar line of the curve. Therefore, the accuracy is lower, and MaxErr is not minimal, but as a bonus, the  Table 9 shows the Bresenham's decision functions for the three tripods. The object of the paper is to represent the 3D IPOs as clearly as possible, therefore the While loop of the Bresenham' 3D-IPO will not be presented in incremental form.

Possible but not implemented incremental updates:
As stated in § 4.  + f T P P W P can be incremental updated. The object of the paper is to represent the 3D IPOs as clearly as possible, therefore the while loops of the Bresenham' 3D-curve-IPO will not be presented in incremental form. The Bresenham-updates are easier than the RMDPL-updates, that can be seen from the first equation of (16) and the update equation (18 Version 1: Monday, July 19, 2021 P a g e | 32

Conclusion
The paper presented three new 26-connected constant feedrate IPOs that can be used in practical situations in CNC machining tools. The RMDPL-IPOs generate perfect 3D-lines or curves with minimal MaxErr. A simple embedded microprocessor, for example the 32-bit PIC32, can easily and fast generate the interrupts and the computations in C or C++. The less accurate but super-fast Bresenham-3D-curve-IPO can be used in many practical situations as MaxErr is bounded to . Quadrics and QSICs are basic objects of CAD/CAM Systems. The criterion of the Relative Minimal Distance of two pairwise candidate points to the Polar Line of the curve (QSIC) and cascading the ultra-fast PRM-cs to 26-connected curves are crucial. Theoretical, the RMDPL is fundamental, it is the core of all the successful 2D-incremental step algorithms and this paper proves that it is the core of the 3D incremental step algorithms or 3D reference IPOs. Many papers (Bresenham 2D-line and circle algorithms, Van Aken's & Pitteway's midpoint algorithms, and all the incremental algorithms of the NATO ASI Series F books [33; 34] given to me by J. E. Bresenham) tried to explain the 2D-incremental step algorithms, the conflicts between the results of the midpoint and two-point methods (OoA errors). The sampling of curves was theorical clear and solved the constant feedrate problem. Now, the theoretical background of 2D and 3D incremental-step curves is clear [2], the OoA-and the OoCproblems are solved and implementing constant feedrate with high accuracy to a 26-connected curve turns out to be piece of cake in contrast with the sampled-data curves. CNC machining tools which use RMDPL will be simpler, faster, and more accurate than the current machining tools based on sampled-data systems. All IPOs can be converted to constant feedrate listSIM-IPOs which can be used in real time in simplified rigid CNC machine tools [1;4, § 7].   Table 10 the sign "≤" is replaced by the signs "<" and "≡", hence one gets, when Bd23 is true and {Bd21, Bd31} when BD23 is false. Therefore, both algorithms select point P1 for the decimal row "5", but for the decimal row "2", the RMDPL criterion selects point P2 and the Bresenham algorithm selects point P3.