The STL Format
Standard Data Format of STL
Reprinted from http://www.fabbers.com/tech/STL_Format Reprinted from Section 6.5 of Automated Fabrication by Marshall Burns, Ph.D. Technical source: StereoLithography Interface Specification, 3D Systems, Inc., October 1989
An STL (“StereoLithography”) file is a triangular representation of a 3dimensional surface geometry. The surface is tessellated or broken down logically into a series of small triangles (facets). Each facet is described by a perpendicular direction and three points representing the vertices (corners) of the triangle. These data are used by a slicing algorithm to determine the cross sections of the 3dimensional shape to be built by the fabber.
Format Specifications
An STL file consists of a list of facet data. Each facet is uniquely identified by a unit normal (a line perpendicular to the triangle and with a length of 1.0) and by three vertices (corners). The normal and each vertex are specified by three coordinates each, so there is a total of 12 numbers stored for each facet.
Facet orientation. The facets define the surface of a 3dimensional object. As such, each facet is part of the boundary between the interior and the exterior of the object. The orientation of the facets (which way is “out” and which way is “in”) is specified redundantly in two ways which must be consistent. First, the direction of the normal is outward. Second, the vertices are listed in counterclockwise order when looking at the object from the outside (righthand rule). These rules are illustrated in Figure 1.
Figure 1. Orientation of a facet is determined by the direction of the unit normal and the order in which the vertices are listed.
Vertextovertex rule. Each triangle must share two vertices with each of its adjacent triangles. In other words, a vertex of one triangle cannot lie on the side of another. This is illustrated in Figure 2.
Figure 2. The vertextovertex rule. The left figure shows a violation of the rule. A correct configuration is shown on the right.
The object represented must be located in the allpositive octant. In other words, all vertex coordinates must be positivedefinite (nonnegative and nonzero) numbers. The STL file does not contain any scale information; the coordinates are in arbitrary units.
The official 3D Systems STL specification document states that there is a provision for inclusion of “special attributes for building parameters,” but does not give the format for including such attributes. Also, the document specifies data for the “minimum length of triangle side” and “maximum triangle size,” but these numbers are of dubious meaning.
Sorting the triangles in ascending zvalue order is recommended, but not required, in order to optimize performance of the slice program.
The STL standard includes two data formats, ASCII and binary. We will introduce ASCII formart only.
STL ASCII Format
The ASCII format is primarily intended for testing new CAD interfaces. The large size of its files makes it impractical for general use. The syntax for an ASCII STL file is as follows:


The syntax for facet unit is:


More about STL format
https://all3dp.com/whatisstlfileformatextension3dprinting/ https://en.wikipedia.org/wiki/STL_(file_format)