SetPoint() public method

public SetPoint ( Vector2 point ) : void
point Vector2
return void
Ejemplo n.º 1
0
        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 = 1; i < vertices.Length; i++)
            {
                GraphEdge ge = new GraphEdge(vertices[i - 1], vertices[i]);

                System.Diagnostics.Debug.Assert(ge.Point1 != ge.Point2);

                Edges.Add(ge);
            }

            GraphEdge lastEdge = new GraphEdge(vertices[0], vertices[vertices.Length - 1]);

            Edges.Add(lastEdge);

            Site = new Site();
            Site.SetPoint(midPoint);
        }
        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);
        }