Exemple #1
0
        /// <summary>
        /// Method  to build a Rectangulo with vertice1 and vertice3
        /// </summary>
        /// <param name="vertice1">Class Punto</param>
        /// <param name="vertice3">Class Punto</param>
        public Rectangulo(Punto vertice1, Punto vertice3)
        {
            int puntosX;
            int puntosY;

            //With vertice1 and vertice3 calculate the other vertices
            //using method Abs from Math
            puntosX = Math.Abs(vertice1.GetX() - vertice3.GetX());
            puntosY = Math.Abs(vertice1.GetY() - vertice3.GetY());

            //All vertices for the Rectangulo
            this.vertice1 = vertice1;
            this.vertice2 = new Punto(vertice1.GetX() + puntosX, vertice1.GetY());
            this.vertice3 = vertice3;
            this.vertice4 = new Punto(vertice1.GetX(), vertice1.GetY() + puntosY);
        }
Exemple #2
0
        /// <summary>
        /// Calculate height of Rectangulo
        /// </summary>
        /// <returns>The height of rectangulo</returns>
        private float CalcularHeightRectangulo()
        {
            float heightRectangulo;

            heightRectangulo = Math.Abs(vertice1.GetY() - vertice3.GetY());
            return(heightRectangulo);
        }
Exemple #3
0
        public int Altura(Punto dos)
        {
            //Altura
            //Necesito que yVertice2 sea SIEMPRE positivo.

            int yVertice2        = Math.Abs(dos.GetY());
            int yVertice1        = Math.Abs(this.vertice1.GetY());
            int alturaRectangulo = yVertice2 - yVertice1;

            return(alturaRectangulo);
        }