Nez.Portable/Physics/Shapes/Polygon.cs
/// <summary>
/// builds the Polygon edge normals. These are lazily created and updated only by the edgeNormals getter
/// </summary>
builds the Polygon edge normals. These are lazily created and updated only by the edgeNormals getter
builds the Polygon edge normals . These are lazily created and updated only by the edgeNormals getter
void buildEdgeNormals()
        {
            var totalEdges = isBox ? 2 : points.Length;
            if (_edgeNormals == null || _edgeNormals.Length != totalEdges)
                _edgeNormals = new Vector2[totalEdges];
            Vector2 p2;
            for (var i = 0; i < totalEdges; i++)
            {
                var p1 = points[i];
                if (i + 1 >= points.Length)
                    p2 = points[0];
                else
                    p2 = points[i + 1];
                var perp = Vector2Ext.perpendicular(ref p1, ref p2);
                Vector2Ext.normalize(ref perp);
                _edgeNormals[i] = perp;
            }
            return;
        }
void buildEdgeNormals ( ) { var totalEdges = isBox ? 2 : points . Length ; if ( _edgeNormals == null || _edgeNormals . Length != totalEdges ) _edgeNormals = new Vector2 [ totalEdges ] ; Vector2 p2 ; for ( var i = 0 ; i < totalEdges ; i ++ ) { var p1 = points [ i ] ; if ( i + 1 >= points . Length ) p2 = points [ 0 ] ; else p2 = points [ i + 1 ] ; var perp = Vector2Ext . perpendicular ( ref p1 , ref p2 ) ; Vector2Ext . normalize ( ref perp ) ; _edgeNormals [ i ] = perp ; } return ; }
builds the Polygon edge normals.
builds the Polygon edge normals .
// for boxes we only require 2 edges since the other 2 are parallel