private void pushGraphEdge( Site leftSite, Site rightSite, Vector2 point1, Vector2 point2 )
 {
     GraphEdge newEdge = new GraphEdge(point1, point2);
     allEdges.Add ( newEdge );
         
     newEdge.site1 = leftSite;
     newEdge.site2 = rightSite;
 }
Beispiel #2
0
        private void pushGraphEdge(Site leftSite, Site rightSite, double x1, double y1, double x2, double y2) {
            GraphEdge newEdge = new GraphEdge();
            allEdges.Add(newEdge);
            newEdge.x1 = x1;
            newEdge.y1 = y1;
            newEdge.x2 = x2;
            newEdge.y2 = y2;

            newEdge.site1 = leftSite.sitenbr;
            newEdge.site2 = rightSite.sitenbr;
        }
Beispiel #3
0
        private void pushGraphEdge(Site leftSite, Site rightSite, float x1, float y1, float x2, float y2)
        {
            GraphEdge graphEdge = new GraphEdge();

            allEdges.Add(graphEdge);
            graphEdge.x1    = x1;
            graphEdge.y1    = y1;
            graphEdge.x2    = x2;
            graphEdge.y2    = y2;
            graphEdge.site1 = leftSite.sitenbr;
            graphEdge.site2 = rightSite.sitenbr;
        }
        public VoronoiCell(Vector2[] vertices)
        {
            Edges = new List<GraphEdge>();
            BodyVertices = new List<Vector2>();

            Vector2 midPoint = Vector2.Zero;
            foreach (Vector2 vertex in vertices)
            {
                midPoint += vertex;
            }
            midPoint /= vertices.Length;

            for (int i = 0; i < vertices.Length; i++)
            {
                GraphEdge ge = new GraphEdge(vertices[i], vertices[MathUtils.PositiveModulo(i + 1, vertices.Length)]);
                System.Diagnostics.Debug.Assert(ge.Point1 != ge.Point2);
                Edges.Add(ge);
            }

            Site = new Site();
            Site.SetPoint(midPoint);
        }
 public VoronoiCell getAdjacentCellFromEdge(GraphEdge edge)
 {
     return(edge.cell1 == this ? edge.cell2 : edge.cell1);
 }