## 2 Literature Review
### Non-Planar Path Planning for 3D Printing
For proper curved printing, the extruder needs to travel linearly from point to point without collisions with the target, so the distance between each point needs to be small enough to have a smooth path. Therefore, the algorithm verifies that the distance between each pair of consecutive points is correct before projecting them, and in cases where the distance is larger than 0.5 mm or 1 mm (user-defined variable), extra points equally spaced are parametrically generated to allow the extruder to travel conformally on the curved surface without collisions, as shown in Figure 4, where the line \(P_{0}-P_{1}\) needs to be subdivided before being projected for successful printing by using the parametric equation \(P(u)=(1-u)P_{0}+uP_{1}\), where \(0\leq u\leq 1\). The distance between two consecutive points might change after projection since the points might cross the model at different heights (z-values) once it is projected, as shown in Figure 5.  
Step 3. Calculating plane equations and centroids:  
Consider a point \(P_{0}\), which belongs to the infinite plane \(\mathbf{Q}\) defined by a point \(\mathbf{C}\) and a normal vector \(\overrightarrow{n}\). The generalized plane's equation for each triangle is calculated, using its normal and centroid, using the equation of a plane (see Definition A2 in Appendix A). \[\overrightarrow{n}P_{i}+d=0 \tag{1}\]  
Figure 4: Subdividing a line \(P_{0}-P_{1}\) before projection to avoid collisions and achieve proper printing. Figure 5: The initial distance between two points might be different after projection: \(d_{initial}\
eq d_{projected}\). Therefore, taking Equation (1) for the specific case of a triangle, and if the centroid \(\mathbf{C}(c_{x},c_{y},c_{z})\) of a triangle (defined by three vertices \((V_{1},V_{2},V_{3})\) is calculated as \(((V_{1x}+V_{2x}+V_{3x})/3\), \((V_{1y}+V_{2y}+V_{3y})/3(V_{1z}+V_{2z}+V_{3z})/3))\) and its normal vector is \(\overrightarrow{n^{\prime}}(n_{x},n_{y},n_{z})\), then the scalar equation of the infinite plane \(\mathbf{Q}\), where the three vertices and centroid of the triangle are located, is given by Equation (2):  
\[n_{x}x+n_{y}y+n_{z}z+(-c_{x}n_{x}-c_{y}n_{y}-c_{z}n_{z})=0 \tag{2}\]  
_Step 4: Calculate the intersection of a projected point and a plane:_  
Consider Figure 6, where a point \(P_{0}\) is projected in a vector direction \(\overrightarrow{v}\). This infinite-line of projection can be described by its parametric equation (see Definition A3 in Appendix A). Having described an infinite plane through Equation (2) and an infinite-line through \(P=P_{0}+t\overrightarrow{v}\), the point of intersection between both can be found by substituting the infinite-line equation onto the infinite plane equation so that the following holds:  
\[\overrightarrow{n}(P_{0}+t\overrightarrow{v})+d=0 \tag{3}\]  
and solving for \(t\),  
\[t=\frac{-(d+\overrightarrow{n}P_{0})}{\overrightarrow{v}} \tag{4}\]  
knowing \(t\), the coordinates of the intersection point are calculated as follows:  
\[ \begin{array}{l}x=P_{0x}+t\ v_{x}\\ y=P_{0y}+t\ v_{y}\\ z=P_{0z}+t\ v_{z}\end{array}  \tag{5}\]  
_Step 5: Finding the intersection of the projected point with true triangles:_  
Equation (5) is used to obtain the intersection of the projected point with the infinite plane of every triangle of the STL model, as shown in Figure 6. However, using the equation of a point inside a triangle (see Definition A4 in Appendix A), the vertices are used to delimit each triangle's space and validate that the projected point intersects the triangles. _Step 6: Finding the intersection with the upper surface of the STL model:_  
Once the algorithm finds which triangles are intersected by the projected point and the location \((x,y,z)\) of the intersection, the algorithm holds the intersection only with the upper surface.