Exemple #1
0
        public Complejo Cociente(Complejo divisor)
        {
            Complejo resultado = new Complejo(Math.Round(modulo / divisor.modulo, 4), Math.Round(angulo - divisor.angulo, 4), "Polar");

            resultado.CorregirAngulos();
            return(resultado);
        }
Exemple #2
0
 private void buttonTipo_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBoxTransformacion.Text))
     {
         MessageBox.Show("No hay complejo para transformar", "Error", MessageBoxButtons.OK);
     }
     else
     {
         Complejo complejo = new Complejo(textBoxTransformacion.Text);
         if (complejo.tipoOriginal == "Binomial")
         {
             labelComplejoEnForma.Text = "Complejo en forma: " + complejo.tipoOriginal;
             labelTransformado.Text    = complejo.parteReal.ToString() + " + " + complejo.parteImaginaria.ToString() + "j";
         }
         else if (complejo.tipoOriginal == "Polar")
         {
             labelComplejoEnForma.Text = "Complejo en forma: " + complejo.tipoOriginal;
             labelTransformado.Text    = "modulo: " + Math.Abs(complejo.modulo).ToString() + "    angulo: " + complejo.angulo.ToString();
         }
         else
         {
             MessageBox.Show("Error ingresando los datos", "Error", MessageBoxButtons.OK);
             labelComplejoEnForma.Text = "";
             labelTransformado.Text    = "";
             labelTransformar.Text     = "";
         }
     }
 }
Exemple #3
0
        public Complejo Multiplicacion(Complejo multiplicado)
        {
            Complejo resultado = new Complejo(Math.Round(modulo * multiplicado.modulo, 4), Math.Round(angulo + multiplicado.angulo, 4), "Polar");//angulo perteneciente a {0,2pi}

            resultado.CorregirAngulos();
            return(resultado);
        }
Exemple #4
0
 private void ButtonPotencia_Click(object sender, EventArgs e)
 {
     labelPrimitivas.Hide();
     labelAngulo.Hide();
     listView1.Items.Clear();
     if (string.IsNullOrWhiteSpace(textBoxComplejo.Text) || string.IsNullOrWhiteSpace(textBoxFactor.Text))
     {
         MessageBox.Show("Fata complejo o factor", "Error", MessageBoxButtons.OK);
     }
     else
     {
         Complejo complejo = new Complejo(textBoxComplejo.Text);
         Int32    potencia = new Int32();
         if ((complejo.tipoOriginal == "Binomial" || complejo.tipoOriginal == "Polar") && Int32.TryParse(textBoxFactor.Text, out potencia))
         {
             Complejo resultado = complejo.Potencia(potencia);
             resultado.modulo         = Math.Round(resultado.modulo, 4);
             resultado.angulo         = Math.Round(resultado.angulo, 4);
             labelResultBinomial.Text = resultado.parteReal.ToString() + " + " + resultado.parteImaginaria.ToString() + "j";
             labelResultPolar.Text    = "modulo: " + Math.Abs(resultado.modulo).ToString() + "    angulo: " + resultado.angulo.ToString();
             labelResultBinomial.Show();
             labelResultPolar.Show();
         }
         else
         {
             MessageBox.Show("Error ingresando los datos", "Error", MessageBoxButtons.OK);
         }
     }
 }
Exemple #5
0
 private void ButtonRadicacion_Click(object sender, EventArgs e)
 {
     labelResultBinomial.Hide();
     labelResultPolar.Hide();
     if (string.IsNullOrWhiteSpace(textBoxComplejo.Text) || string.IsNullOrWhiteSpace(textBoxFactor.Text))
     {
         MessageBox.Show("Fata complejo o factor", "Error", MessageBoxButtons.OK);
     }
     else
     {
         Complejo complejo = new Complejo(textBoxComplejo.Text);
         Int32    factor   = new Int32();
         if ((complejo.tipoOriginal == "Binomial" || complejo.tipoOriginal == "Polar") && Int32.TryParse(textBoxFactor.Text, out factor))
         {
             Complejo[] raices = complejo.Radicacion(factor);
             foreach (Complejo c in raices)
             {
                 c.angulo = Math.Round(c.angulo, 4);
                 c.modulo = Math.Round(c.modulo, 4);
             }
             labelAngulo.Text = "Fórmula: " + raices[0].angulo.ToString() + "+2.K.pi/" + factor;
             //ListViewItem[] items = new ListViewItem[factor];
             listView1.Items.Clear();
             int i = 0;
             foreach (Complejo c in raices)
             {
                 ListViewItem item = new ListViewItem("W" + i);
                 item.SubItems.Add(c.modulo.ToString());
                 item.SubItems.Add(c.angulo.ToString());
                 listView1.Items.Add(item);
                 //items[i] = item;
                 i++;
             }
             if (complejo.modulo == 1 && complejo.angulo == 0)
             {
                 string primitivas;
                 primitivas = "Raices Primitivas:\n";
                 for (int j = 0; j < raices.Length; j++)
                 {
                     if (mcd(j, factor) == 1)
                     {
                         primitivas = primitivas + "W" + j.ToString() + ", ";
                     }
                 }
                 labelPrimitivas.Text = primitivas.Substring(0, primitivas.Length - 2);
                 labelPrimitivas.Show();
                 listView1.Refresh();
             }
             else
             {
                 labelPrimitivas.Hide();
             }
         }
         else
         {
             MessageBox.Show("Error ingresando los datos", "Error", MessageBoxButtons.OK);
         }
     }
 }
Exemple #6
0
        public Complejo Potencia(Int32 potencia)
        {
            Complejo resultado = new Complejo(Math.Pow(modulo, potencia), angulo * potencia, "Polar");

            resultado.CorregirAngulos();

            return(resultado);
        }
Exemple #7
0
        public Complejo[] Radicacion(Int32 factor)
        {
            Complejo[] raices = new Complejo[factor];
            double     a;
            double     m = Math.Pow(modulo, ((double)(1) / factor));

            for (int i = 0; i < factor; i++)
            {
                a         = ((angulo + 2 * i * Math.PI) / factor) * 360 / 2 / Math.PI; // angulo en grados
                raices[i] = new Complejo(m, a, "Polar");
            }

            return(raices);
        }
Exemple #8
0
        public string MostrarTransformado(Complejo complejo)
        {
            string s = "0";

            if (complejo.tipoOriginal == "Binomial")
            {
                s = ("[" + complejo.modulo.ToString() + ";" + complejo.angulo.ToString() + "]");
                return(s);
            }
            else if (complejo.tipoOriginal == "Polar")
            {
                s = ("(" + complejo.parteReal.ToString() + "," + complejo.parteImaginaria.ToString() + ")");
                return(s);
            }

            return(s);
        }
Exemple #9
0
 private void buttonTransformar_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBoxTransformacion.Text))
     {
         MessageBox.Show("No hay complejo para transformar", "Error", MessageBoxButtons.OK);
     }
     else
     {
         Complejo complejo = new Complejo(textBoxTransformacion.Text);
         if (complejo.tipoOriginal == "Binomial" || complejo.tipoOriginal == "Polar")
         {
             labelTransformar.Text = complejo.MostrarTransformado(complejo);
         }
         else
         {
             MessageBox.Show("Error ingresando los datos", "Error", MessageBoxButtons.OK);
         }
     }
 }
Exemple #10
0
 private void buttonCociente_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBoxNum1.Text) || string.IsNullOrWhiteSpace(textBoxNum2.Text))
     {
         MessageBox.Show("Falta un complejo para realizar la operacion", "Error", MessageBoxButtons.OK);
     }
     else
     {
         Complejo complejo1 = new Complejo(textBoxNum1.Text);
         Complejo complejo2 = new Complejo(textBoxNum2.Text);
         if ((complejo1.tipoOriginal == "Binomial" || complejo1.tipoOriginal == "Polar") && (complejo2.tipoOriginal == "Binomial" || complejo2.tipoOriginal == "Polar"))
         {
             Complejo resultado = complejo1.Cociente(complejo2);
             resultado.modulo            = Math.Round(resultado.modulo, 4);
             resultado.angulo            = Math.Round(resultado.angulo, 4);
             labelResultadoBinomica.Text = resultado.parteReal.ToString() + " + " + resultado.parteImaginaria.ToString() + "j";
             labelResultadoPolar.Text    = "modulo: " + Math.Abs(resultado.modulo).ToString() + "    angulo: " + resultado.angulo.ToString();
         }
         else
         {
             MessageBox.Show("Error ingresando los datos", "Error", MessageBoxButtons.OK);
         }
     }
 }
Exemple #11
0
 public Complejo Resta(Complejo restado)
 {
     return(new Complejo(parteReal - restado.parteReal, parteImaginaria - restado.parteImaginaria, "Binomial"));
 }
Exemple #12
0
 public Complejo Suma(Complejo sumado)
 {
     return(new Complejo(parteReal + sumado.parteReal, parteImaginaria + sumado.parteImaginaria, "Binomial"));
 }