Ejemplo n.º 1
0
        public InternalObstacle(Vector2[] vertices)
        {
            if (vertices.Length < 3)
            {
                throw new Exception("Vertices count of polygonal obstacle should be >2");
            }

            // содомитство для удобства алгоритмов - повторим первую и вторую точку в конец вектора
            this.vertices = new Vector2[vertices.Length + 2];
            Array.Copy(vertices, 0, this.vertices, 0, vertices.Length);
            this.vertices[this.vertices.Length - 2] = vertices[0];
            this.vertices[this.vertices.Length - 1] = vertices[1];

            UpdateGeometry();
            Bounds = new InternalBox(vertices);
        }
Ejemplo n.º 2
0
 public void Add(InternalBox other)
 {
     LeftBottom = new Vector2(Math.Min(other.LeftBottom.x, LeftBottom.x), Math.Min(other.LeftBottom.y, LeftBottom.y));
     RightTop   = new Vector2(Math.Max(other.RightTop.x, RightTop.x), Math.Max(other.RightTop.y, RightTop.y));
 }