Пример #1
0
        /// <summary>
        ///
        /// CONTINUA CON EL SEGUNDO PASO DE LA EXPLICACION EN EL METODO PASO A PASO
        ///
        /// </summary>
        ///
        private void btContinuar_Click(object sender, EventArgs e)
        {
            lbExplicacion.Text += " \n Esto es así, porque la distancia entre los dos puntos es la hipotenusa del triangulo rectangulo formado por el vector entre los puntos y sus proyecciones sobre los planos ortogonales.";
            // Pintar el vector
            ventanagrafica.PintarVector(punto1, punto2, Color.Chartreuse, 6, true);
            string pto1X;

            if (punto1.X.ToString() != "")
            {
                pto1X = punto1.X.ToString();
            }
            else
            {
                pto1X = "0";
            }

            string pto1Y;

            if (punto1.Y.ToString() != "")
            {
                pto1Y = punto1.Y.ToString();
            }
            else
            {
                pto1Y = "0";
            }

            string pto1Z;

            if (punto1.Z.ToString() != "")
            {
                pto1Z = punto1.Z.ToString();
            }
            else
            {
                pto1Z = "0";
            }

            string pto2X;

            if (punto2.X.ToString() != "")
            {
                pto2X = punto2.X.ToString();
            }
            else
            {
                pto2X = "0";
            }

            string pto2Y;

            if (punto2.Y.ToString() != "")
            {
                pto2Y = punto2.Y.ToString();
            }
            else
            {
                pto2Y = "0";
            }

            string pto2Z;

            if (punto2.Z.ToString() != "")
            {
                pto2Z = punto2.Z.ToString();
            }
            else
            {
                pto2Z = "0";
            }

            // Pintar las lineas que forman los catetos del triangulo rectangulo
            if (punto2.Z > punto1.Z)
            {
                ventanagrafica.PintarLinea(punto1, new Punto(pto2X + " " + pto2Y + " " + pto1Z), Color.Coral, 0.5F);
                ventanagrafica.PintarLinea(new Punto(pto2X + " " + pto2Y + " " + (pto1Z)), punto2, Color.Aquamarine, 0.5f);
                ventanagrafica.PintarString(new Punto(new Racional[] { (punto1.X + punto2.X) / 2, (punto1.Y + punto2.Y) / 2, punto1.Z }), Color.Coral, 13, "√ ( (" + Racional.AString(punto1.X) + " - " + Racional.AString(punto2.X) + " )^2 + ( " + Racional.AString(punto1.Y) + " - " + Racional.AString(punto2.Y) + " )^2 )");
                ventanagrafica.PintarString(new Punto(new Racional[] { punto2.X, punto2.Y, (punto1.Z + punto2.Z) / 2 }), Color.Aquamarine, 13, Racional.AString(punto1.Z) + " - " + Racional.AString(punto2.Z));
            }
            else
            {
                ventanagrafica.PintarLinea(punto2, new Punto(pto1X + " " + pto1Y + " " + pto2Z), Color.Coral, 0.5f);
                ventanagrafica.PintarLinea(new Punto(pto1X + " " + pto1Y + " " + pto2Z), punto1, Color.Aquamarine, 0.5f);
                ventanagrafica.PintarString(new Punto(new Racional[] { (punto1.X + punto2.X) / 2, (punto1.Y + punto2.Y) / 2, punto2.Z }), Color.Coral, 13, "√ ( (" + Racional.AString(punto1.X) + " - " + Racional.AString(punto2.X) + " )^2 + ( " + Racional.AString(punto1.Y) + " - " + Racional.AString(punto2.Y) + " )^2 )");
                ventanagrafica.PintarString(new Punto(new Racional[] { punto1.X, punto1.Y, (punto1.Z + punto2.Z) / 2 }), Color.Aquamarine, 13, Racional.AString(punto1.Z) + " - " + Racional.AString(punto2.Z));
            }

            btContinuar.Click -= btContinuar_Click;
            btContinuar.Click += btContinuar2_Click;
            for (int i = 0; i < 3; i++)
            {
                btArriba.PerformClick();
            }
            ventanagrafica.Ventana.Invalidate();
        }
Пример #2
0
        /// <summary>
        ///
        /// CONSTRUYE LOS DOS VECTORES A SUMAR O RESTAR SEGUN LOS DATOS INTRODUCIDOS EN LAS CAJAS
        /// DE LAS COMPONENTES Y LOS REPRESENTA EN PANTALLA
        ///
        /// </summary>
        ///
        private void IniciarResolucion()
        {
            // Mostrar los controles
            lbTituloAnguloX.Visible = true; btIsometrica.Visible = true;
            lbAnguloX.Visible       = true; btAlzado.Visible = true;
            sbAngulox.Visible       = true; btPerfil.Visible = true;
            lbTituloAnguloY.Visible = true; btPlanta.Visible = true;
            lbAnguloY.Visible       = true;
            sbAnguloY.Visible       = true;
            lbTituloAnguloZ.Visible = true;
            lbAnguloZ.Visible       = true;
            sbAnguloZ.Visible       = true;
            btZoomMas.Visible       = true;
            btZoomMenos.Visible     = true;
            lbZoomtitulo.Visible    = true;
            lbAjustar.Visible       = true;
            btAjustar.Visible       = true;
            pnZoom.Visible          = true;
            btAbajo.Visible         = true;
            btArriba.Visible        = true;
            btDerecha.Visible       = true;
            btIzquierda.Visible     = true;
            btCentrar.Visible       = true;
            btContinuar.Visible     = true;

            if (defecto)
            {
                punto1                = new Punto("26 10 25");
                tbPunto1X.Text        = Racional.AString(punto1.X);
                tbPunto1Y.Text        = Racional.AString(punto1.Y);
                tbPunto1Z.Text        = Racional.AString(punto1.Z);
                punto2                = new Punto("14 30 5");
                tbPunto2X.Text        = Racional.AString(punto2.X);
                tbPunto2Y.Text        = Racional.AString(punto2.Y);
                tbPunto2Z.Text        = Racional.AString(punto2.Z);
                ventanagrafica.Escala = 1.3F;
            }

            vector1 = new Vector(tbPunto1X.Text + " " + tbPunto1Y.Text + " " + tbPunto1Z.Text);
            vector2 = new Vector(tbPunto2X.Text + " " + tbPunto2Y.Text + " " + tbPunto2Z.Text);
            punto1  = new Punto(tbPunto1X.Text + " " + tbPunto1Y.Text + " " + tbPunto1Z.Text);
            punto2  = new Punto(tbPunto2X.Text + " " + tbPunto2Y.Text + " " + tbPunto2Z.Text);
            // Pintar los vectores
            ventanagrafica.PintarVector(new Punto("0 0 0"), new Punto(tbPunto1X.Text + " " + tbPunto1Y.Text + " " + tbPunto1Z.Text), Color.DarkOrange, 7, true);
            ventanagrafica.PintarVector(new Punto("0 0 0"), new Punto(tbPunto2X.Text + " " + tbPunto2Y.Text + " " + tbPunto2Z.Text), Color.SlateBlue, 7, true);
            btIsometrica.PerformClick();
            if (!defecto)
            {
                btAjustar.PerformClick();
            }
            if (!directa)
            {
                lbExplicacion.Text = " El ángulo entre dos vectores θ, se mide sobre el plano que los contiene a ambos.\n La fórmula para calcularlo es: cos θ = ( U * V ) / ( |U| * |V| ).\n Esta fórmula se extrae de la ley de los cosenos: | W |² = | U |² + |V|² - 2 |U| * |V| * cos θ.  Pulse el botón [ Demostración ] para ver como se extrae. ";
            }
            // Pintar el plano entre los vectores
            Punto final1 = new Punto(new Racional[] { vector1.Componentes[0] / 2, vector1.Componentes[1] / 2, vector1.Componentes[2] / 2 });
            Punto final2 = new Punto(new Racional[] { vector2.Componentes[0] / 2, vector2.Componentes[1] / 2, vector2.Componentes[2] / 2 });

            ventanagrafica.PintarSuperficie(new Punto[] { final1, final2, new Punto("0 0 0") }, Color.Chartreuse, false);
            //Pintar las letras que identifican cada vector
            Punto  situacionU = Punto.PuntoMedio(new Punto("0 0 0"), new Punto(vector1.Componentes));
            PointF finalv1    = ventanagrafica.PuntoAPoint(new Punto(vector1.Componentes));
            double pendiente  = finalv1.Y / finalv1.X;

            situacionU.Coordenadas[1] -= 1;
            situacionU.Coordenadas[2] -= 1;
            Punto situacionV = Punto.PuntoMedio(new Punto("0 0 0"), new Punto(vector2.Componentes));

            situacionV.Coordenadas[1] -= 1;
            situacionV.Coordenadas[2] -= 1;
            ventanagrafica.PintarString(situacionU, Color.Orange, 14, "U");
            ventanagrafica.PintarString(situacionV, Color.SlateBlue, 14, "V");
            // Mover las etiquetas para dejar sitio a los signos de multiplicar y el desarrollo de las operaciones
            label35.Location   = new Point(label35.Location.X, label35.Location.Y - 15);
            label36.Location   = new Point(label36.Location.X, label36.Location.Y - 15);
            label37.Location   = new Point(label37.Location.X, label37.Location.Y - 15);
            lbRotuloA.Location = new Point(lbRotuloA.Location.X, lbRotuloA.Location.Y - 15);
            tbPunto1X.Location = new Point(tbPunto1X.Location.X, tbPunto1X.Location.Y - 15);
            tbPunto1Y.Location = new Point(tbPunto1Y.Location.X, tbPunto1Y.Location.Y - 15);
            tbPunto1Z.Location = new Point(tbPunto1Z.Location.X, tbPunto1Z.Location.Y - 15);
            // Mostrar las etiquetas con los signos
            label1.Show();
            label1.Text      = "*";
            label1.BackColor = Color.Transparent;
            label1.Font      = new Font(label1.Font.FontFamily, 15, FontStyle.Bold);
            pnDatos.Controls.Add(label1);
            label1.Location = new Point(tbPunto1X.Location.X + (tbPunto1X.Width / 2) - 5, (tbPunto1X.Location.Y + tbPunto2X.Location.Y) / 2 + 2);

            label2.Show();
            label2.Text      = "*";
            label2.BackColor = Color.Transparent;
            label2.Font      = new Font(label1.Font.FontFamily, 15, FontStyle.Bold);
            pnDatos.Controls.Add(label2);
            label2.Location = new Point(tbPunto1Y.Location.X + (tbPunto1Y.Width / 2) - 5, label1.Location.Y);

            label3.Show();
            label3.Text      = "*";
            label3.BackColor = Color.Transparent;
            label3.Font      = new Font(label1.Font.FontFamily, 15, FontStyle.Bold);
            pnDatos.Controls.Add(label3);
            label3.Location = new Point(tbPunto1Z.Location.X + (tbPunto1Z.Width / 2) - 5, label1.Location.Y);

            label4.Show();
            label4.Text = Racional.AString(vector1.Componentes[0] * vector2.Componentes[0]);
            label4.Font = new Font(label1.Font.FontFamily, 10, FontStyle.Bold);
            pnDatos.Controls.Add(label4);
            label4.Location  = new Point(tbPunto1X.Location.X, tbPunto2X.Location.Y + tbPunto2X.Height);
            label4.BackColor = Color.Transparent;

            label5.Show();
            label5.BackColor = Color.Transparent;
            label5.Text      = " + ";
            label5.Font      = new Font(label1.Font.FontFamily, 10, FontStyle.Bold);
            pnDatos.Controls.Add(label5);
            label5.Location  = new Point(tbPunto1X.Location.X + tbPunto2X.Width, label4.Location.Y);
            label4.BackColor = Color.Transparent;

            label6.Show();
            label6.Text = Racional.AString(vector1.Componentes[1] * vector2.Componentes[1]);
            label6.Font = new Font(label1.Font.FontFamily, 10, FontStyle.Bold);
            pnDatos.Controls.Add(label6);
            label6.Location  = new Point(tbPunto1Y.Location.X, label5.Location.Y);
            label6.BackColor = Color.Transparent;

            label7.Show();
            label7.BackColor = Color.Transparent;
            label7.Text      = " + ";
            label7.Font      = new Font(label1.Font.FontFamily, 10, FontStyle.Bold);
            pnDatos.Controls.Add(label7);
            label7.Location  = new Point(tbPunto1Y.Location.X + tbPunto2X.Width, label6.Location.Y);
            label7.BackColor = Color.Transparent;

            label8.Show();
            label8.Text = Racional.AString(vector1.Componentes[2] * vector2.Componentes[2]);
            label8.Font = new Font(label1.Font.FontFamily, 10, FontStyle.Bold);
            pnDatos.Controls.Add(label8);
            label8.Location  = new Point(tbPunto1Z.Location.X, label5.Location.Y);
            label8.BackColor = Color.Transparent;

            label9.Show();
            label9.BackColor = Color.Chartreuse;
            label9.Text      = " = " + Racional.AString(vector1 * vector2);
            label9.Font      = new Font(label1.Font.FontFamily, 13, FontStyle.Bold);
            label9.Location  = new Point(pnDatos.Location.X + pnDatos.Width, pnDatos.Location.Y + pnDatos.Height - 21);

            label10.Show();
            label10.Font      = new Font(label8.Font.FontFamily, 9, FontStyle.Underline);
            label10.BackColor = Color.Transparent;
            label10.Text      = "Producto punto (U*V): ";
            pnDatos.Controls.Add(label10);
            label10.Location = new Point(label35.Location.X - 130, label8.Location.Y);

            if (!directa)
            {
                btDemostracion.Show();
            }
            // Mostrar los modulos de los vectores
            label11.Show();
            label11.Font      = new Font(label10.Font.FontFamily, 10, FontStyle.Bold);
            label11.Location  = new Point(btContinuar.Location.X, btContinuar.Location.Y + btContinuar.Height + 5);
            label11.BackColor = Color.Transparent;
            label11.Text      = "Módulo del vector 1 ( | U | ): ";

            label12.Show();
            label12.Font      = new Font(label11.Font.FontFamily, 13, FontStyle.Bold);
            label12.Location  = new Point(label11.Location.X + label11.Width, label11.Location.Y);
            label12.BackColor = Color.DarkOrange;
            label12.Text      = Math.Round(vector1.ModuloDecimal(), 2).ToString();

            label13.Show();
            label13.Font      = new Font(label10.Font.FontFamily, 10, FontStyle.Bold);
            label13.Location  = new Point(btContinuar.Location.X, label11.Location.Y + label11.Height + 10);
            label13.BackColor = Color.Transparent;
            label13.Text      = "Módulo del vector 2 ( | V | ): ";

            label14.Show();
            label14.Font      = new Font(label11.Font.FontFamily, 13, FontStyle.Bold);
            label14.Location  = new Point(label13.Location.X + label13.Width, label13.Location.Y);
            label14.BackColor = Color.SlateBlue;
            label14.Text      = Math.Round(vector2.ModuloDecimal(), 2).ToString();

            // Mostrar la formula del angulo entre vectores
            label15.Show();
            label15.Font      = label14.Font;
            label15.Location  = new Point(btContinuar.Location.X, label14.Location.Y + label14.Height + 5);
            label15.BackColor = Color.LightYellow;
            label15.Text      = "           U * V " + "\ncos Φ = ----------" + "\n             |U| * |V|";

            if (directa)
            {
                paso++;
                lbExplicacion.Hide();
                Finalizar();
            }
        }