public static INumeroComplejo Potenciacion(INumeroComplejo radicando, int indice) { double moduloResultado = Math.Pow(radicando.GetFormaPolar().GetModulo(), indice); double argumentoResultado = radicando.GetFormaPolar().GetArgumento() * indice; return(new NumeroComplejoPolar(moduloResultado, argumentoResultado)); }
public static INumeroComplejo Multiplicar(INumeroComplejo operando1, INumeroComplejo operando2) { double parteRealResultado = operando1.GetParteReal() * operando2.GetParteReal() - operando1.GetParteImaginaria() * operando2.GetParteImaginaria(); double parteImaginariaResultado = operando1.GetParteReal() * operando2.GetParteImaginaria() + operando1.GetParteImaginaria() * operando2.GetParteReal(); return(NumeroComplejoBinomico.NewNumeroComplejoBinomico(parteRealResultado, parteImaginariaResultado)); }
public OperacionesBasicas() { InitializeComponent(); operando1 = null; operando2 = null; resultado = null; }
private void BtnCalcular_Click(object sender, EventArgs e) { lblError.Text = ""; indice = (int)numericUpDownIndice.Value; if (INumeroComplejo.Equals(radicando, null) || indice <= 0) { if (INumeroComplejo.Equals(radicando, null)) { lblError.Text = "Ingrese un número complejo válido"; } if (indice <= 0) { lblError.Text += "ingrese un indice positivo"; } return; } else { listBoxResultados.Items.Clear(); foreach (INumeroComplejo item in OperacionesService.Radicacion(radicando, indice)) { listBoxResultados.Items.Add(item.Show());// } } }
public IFasor SumarEnSen(IFasor sumando) { NumeroComplejoBinomico sumando1 = this.EnSen().EnBinomico(); NumeroComplejoBinomico sumando2 = sumando.EnSen().EnBinomico(); INumeroComplejo resultado = OperacionesService.Sumar(sumando1, sumando2); return(new FasorCoseno(resultado.GetModulo(), this.periodo, resultado.GetArgumento())); }
public static INumeroComplejo Dividir(INumeroComplejo operando1, INumeroComplejo operando2) { INumeroComplejo conjugadoDelSegundoOperando = NumeroComplejoBinomico .NewNumeroComplejoBinomico(operando2.GetParteReal(), operando2.GetParteImaginaria() * (-1)); INumeroComplejo numerador = Multiplicar(operando1, conjugadoDelSegundoOperando); double resultadoProductoDeConjugados = Math.Pow(operando2.GetParteReal(), 2) + Math.Pow(operando2.GetParteImaginaria(), 2); return(NumeroComplejoBinomico.NewNumeroComplejoBinomico(numerador.GetParteReal() / resultadoProductoDeConjugados, numerador.GetParteImaginaria() / resultadoProductoDeConjugados)); }
private void ElegirNumeroYMostrar(ref INumeroComplejo unNumero, ref Label unLabel) { AgregarNumero dialog = new AgregarNumero(); dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.OK) { unNumero = dialog.resultado; unLabel.Text = unNumero.Show(); } }
private void BtnCalcular_Click(object sender, EventArgs e) { if (INumeroComplejo.Equals(numeroComplejo, null)) { lblResultado.Text = "Ingrese un número complejo válido"; } else { lblResultado.Text = OperacionesService.Potenciacion(numeroComplejo, (int)numericUpDownExponente.Value).Show(); } }
private void OkButton_Click(object sender, EventArgs e) { if (estaEnPolar) { resultado = new NumeroComplejoPolar((double)numericUpDownModulo.Value, (double)numericUpDownArgumento.Value * Math.PI); } else { resultado = NumeroComplejoBinomico.NewNumeroComplejoBinomico((double)numericUpDownParteReal.Value, (double)numericUpDownParteImaginaria.Value); } this.DialogResult = DialogResult.OK; }
private void CalcularButton_Click(object sender, EventArgs e) { if (INumeroComplejo.Equals(operando1, null) || INumeroComplejo.Equals(operando2, null)) { resultadoLabel.Text = "Falta asignar algun operando, asignelo y vuelva a intentar"; } else { if (SumaButton.Checked) { //logica de la suma. en lo posible delegar todas las cuentas a un servicio asi queda limpia esta parte del codigo ? resultado = OperacionesService.Sumar(operando1, operando2); } if (RestaButton.Checked) { //resta resultado = OperacionesService.Resta(operando1, operando2); } if (MultiplicacionButton.Checked) { //multiplicacion resultado = OperacionesService.Multiplicar(operando1, operando2); } if (DivisionButton.Checked) { if (operando2.GetFormaPolar().GetModulo() != 0) { resultado = OperacionesService.Dividir(operando1, operando2); } else { resultadoLabel.Text = "No es posible dividir por cero"; return; } } resultadoLabel.Text = resultado.Show(); } }
public static List <INumeroComplejo> Radicacion(INumeroComplejo radicando, int indice) { List <INumeroComplejo> resultado = new List <INumeroComplejo>(); NumeroComplejoPolar operando = radicando.GetFormaPolar(); double moduloResultante = Math.Pow(operando.GetModulo(), 1 / (double)indice); //no hay funcion para hacer la raiz N de un numero, asi que hago la potencia a la 1/N double argumentoResultante = operando.GetArgumento() / indice; NumeroComplejoPolar nuevaRaiz = new NumeroComplejoPolar(moduloResultante, argumentoResultante); double variacionAngulo = 2 * Math.PI / indice; resultado.Add(nuevaRaiz); int i = 1; while (i < indice) { argumentoResultante += variacionAngulo; nuevaRaiz = new NumeroComplejoPolar(moduloResultante, argumentoResultante); resultado.Add(nuevaRaiz); i++; } return(resultado); }