protected void btnkmandmile_Click(object sender, EventArgs e) { if (IsValid) { Mass1 m1 = new Mass1(); if (ddlmass.SelectedValue == "kg") { double input = Convert.ToDouble(txtmass.Text); double result = input * 2.20462; txtmassresult.Text = result.ToString(); m1.datetime = DateTime.Now.ToString(); m1.num1 = txtmass.Text + " kgs"; m1.num2 = "="; m1.result = result.ToString() + " pounds"; } else if (ddlmass.SelectedValue == "pound") { double input = Convert.ToDouble(txtmass.Text); double result = input * 0.453592; txtmassresult.Text = result.ToString(); m1.datetime = DateTime.Now.ToString(); m1.num1 = txtmass.Text + " pounds"; m1.num2 = "="; m1.result = result.ToString() + " kgs"; } else if (ddlmass.SelectedValue == "ounce") { double input = Convert.ToDouble(txtmass.Text); double result = input * 28.3495; txtmassresult.Text = result.ToString(); m1.datetime = DateTime.Now.ToString(); m1.num1 = txtmass.Text + " ounces"; m1.num2 = "="; m1.result = result.ToString() + " grams"; } else if (ddlmass.SelectedValue == "gram") { double input = Convert.ToDouble(txtmass.Text); double result = input * 0.035274; txtmassresult.Text = result.ToString(); m1.datetime = DateTime.Now.ToString(); m1.num1 = txtmass.Text + " grams"; m1.num2 = "="; m1.result = result.ToString() + " ounces"; } m.Add(m1); Session["mass"] = m; } }
public void Solve() { OrbitalPeriodInY = CalcOrbitalPeriod(); var result = CalcMassMagDist(); Distance = result.Item1; AbsoluteMagnitude1 = result.Item2; AbsoluteMagnitude2 = result.Item3; Mass1 = result.Item4; Mass2 = result.Item5; Console.WriteLine($"******** VYSLEDKY ********"); Console.WriteLine($"Obezna doba sustavy {OrbitalPeriodInY.ToString("F")} rokov"); Console.WriteLine($"Vzdialenost sustavy je {Distance.ToString("F")} pc."); Console.WriteLine($"Hviezda 1: hmotnost {Mass1.ToString("G3")} kg, absolutna magnituda {AbsoluteMagnitude1.ToString("F")}."); Console.WriteLine($"Hviezda 2: hmotnost {Mass2.ToString("G3")} kg, absolutna magnituda {AbsoluteMagnitude2.ToString("F")}."); Console.ReadKey(); }
public void Update(GameTime gameTime) { Vector3 springVector = Mass1.PositionCenterEngine - Mass2.PositionCenterEngine; //vector between the two masses float r = springVector.Length(); //distance between the two masses //if (r < SpringLength) { Vector3 force = new Vector3(); //force initially has a zero value if (r != 0) //to avoid a division by zero check if r is zero { force += (springVector / r) * (r - SpringLength) * (-SpringConstant); } //the spring force is added to the force force += -(Mass1.GetVelocity() - Mass2.GetVelocity()) * FrictionConstant; //the friction force is added to the force //with this addition we obtain the net force of the spring Mass1.AddForce(force); //force is applied to mass1 Mass2.AddForce(-force); //the opposite of force is applied to mass2 } }