Está en la página 1de 2

using

using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;

namespace Fuerza_de_Lorentz
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
panelVELOCIDAD.Visible = false;
panelMAGNETICO.Visible = false;
panelRESULTADOS.Visible = false;
}
private void button1_Click(object sender, EventArgs e)
{
panelVELOCIDAD.Visible = true;
textBox1.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
panelMAGNETICO.Visible = true;
textBox2.Enabled = false;
textBox3.Enabled = false;
textBox4.Enabled = false;
}
private void button4_Click(object sender, EventArgs e)
{
int N = 3; // Numero de componentes vectoriales
double q = 0; // variable carga
double[] velocidad = new double[N]; // vector velocidad
double[] magnetico = new double[N]; // vector magnetico
double[] fuerza = new double[N]; // vector fuerza
double F = 0; // magnitud de fuerza

// Inicializamos los arrays a cero


for (int i = 0; i < N; i++)
{
velocidad[i] = 0;
magnetico[i] = 0;
fuerza[i] = 0;
}
q = double.Parse(textBox1.Text);
velocidad[0] = double.Parse(textBox2.Text);
velocidad[1] = double.Parse(textBox3.Text);
velocidad[2] = double.Parse(textBox4.Text);
magnetico[0] = double.Parse(textBox5.Text);
magnetico[1] = double.Parse(textBox6.Text);
magnetico[2] = double.Parse(textBox7.Text);
fuerza[0] = q * (velocidad[1] * magnetico[2] - velocidad[2] * magnetico[1]);
fuerza[1] = - q * (velocidad[0] * magnetico[2] - velocidad[2] * magnetico[0]);
fuerza[2] = q * (velocidad[0] * magnetico[1] - velocidad[1] * magnetico[0]);
F = Math.Sqrt(fuerza[0] * fuerza[0] + fuerza[1] * fuerza[1] + fuerza[2] * fuerza[2]);
// Se visualizan los resultados en la forma
textBox8.Text = "F = " + F.ToString();
textBox9.Text = "F = " + fuerza[0].ToString() + " i " + "+" + fuerza[1].ToString() + " j "
+ "+" + fuerza[2].ToString() + " k ";
}
private void button3_Click(object sender, EventArgs e)
{
panelRESULTADOS.Visible = true;
textBox5.Enabled = false;
textBox6.Enabled = false;
textBox7.Enabled = false;
}
private void button6_Click(object sender, EventArgs e)
{
Close();
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
textBox9.Clear();
textBox1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Enabled = true;
textBox5.Enabled = true;
textBox6.Enabled = true;
textBox7.Enabled = true;
textBox8.Enabled = true;
textBox9.Enabled = true;
}
}

También podría gustarte