src/STLFacetNormal.php
public static function fromString(string $stlFacetNormalString) : STLFacetNormal
    {
        $class = new self();

        preg_match("/facet normal +(\-*\d+\.*\d*e*\-*\+*\d*) +(\-*\d+\.*\d*e*\-*\+*\d*) +(\-*\d+\.*\d*e*\-*\+*\d*)/",
            $stlFacetNormalString, $matches);
        $class->setCoordinatesArray(array((float)$matches[1], (float)$matches[2], (float)$matches[3]));

        $lines = explode("\n", $stlFacetNormalString);
        $vertex = "";
        for ($i = 1; $i < count($lines) - 1; $i++) {
            $vertex .= $lines[$i];
        }
        $class->setVertex(STLVertex::fromString($vertex));

        return $class;
    }
public static function fromString(string $stlFacetNormalString) : STLFacetNormal
    {
        $class = new self();

        preg_match("/facet normal +(\-*\d+\.*\d*e*\-*\+*\d*) +(\-*\d+\.*\d*e*\-*\+*\d*) +(\-*\d+\.*\d*e*\-*\+*\d*)/",
            $stlFacetNormalString, $matches);
        $class->setCoordinatesArray(array((float)$matches[1], (float)$matches[2], (float)$matches[3]));

        $lines = explode("\n", $stlFacetNormalString);
        $vertex = "";
        for ($i = 1; $i < count($lines) - 1; $i++) {
            $vertex .= $lines[$i];
        }
        $class->setVertex(STLVertex::fromString($vertex));

        return $class;
    }
public static function fromString ( string $ stlFacetNormalString ) : STLFacetNormal { $ class = new self ( ) ; preg_match ( "/facet normal +(\-*\d+\.*\d*e*\-*\+*\d*) +(\-*\d+\.*\d*e*\-*\+*\d*) +(\-*\d+\.*\d*e*\-*\+*\d*)/" , $ stlFacetNormalString , $ matches ) ; $ class -> setCoordinatesArray ( array ( ( float ) $ matches [ 1 ] , ( float ) $ matches [ 2 ] , ( float ) $ matches [ 3 ] ) ) ; $ lines = explode ( "\n" , $ stlFacetNormalString ) ; $ vertex = "" ; for ( $ i = 1 ; $ i < count ( $ lines ) - 1 ; $ i ++ ) { $ vertex .= $ lines [ $ i ] ; } $ class -> setVertex ( STLVertex :: fromString ( $ vertex ) ) ; return $ class ; }
Class constructor from an STL facet normal string.

Example facet normal string:

facet normal 0.5651193 -0.07131607 0.8219211
outerloop
vertex -71.74323 47.70205 4.666243
vertex -72.13071 47.70205 4.932664
vertex -72.1506 47.2273 4.905148
endloop
endfacet

@param string $stlFacetNormalString
@return STLFacetNormal
Class constructor from an STL facet normal string .