You are on page 1of 3

Earth Motion

Part 1(form class)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace earthmotion
{
class EarthMotion
{
double X,Y,vx,vy,dt,Pi,r,t;
public EarthMotion(double X,double Y,double vx,double vy,double
dt) //constructer of class
{
this.X=X;
this.Y=Y;
this.vx=vx;
this.vy=vy;
this.dt=dt;
Pi=3.1415;
t=0;
}
public double Xcompute()//calculting final x point
{
vx = vx -( (4 * Pi * Pi * X) / (r * r * r))*dt;
X = X + vx * dt;
return (X);
}
public double Ycompute()//calculting final Y point
{
vy = vy - ((4 * Pi * Pi * Y) / (r * r * r)) * dt;
Y = Y + vy * dt;
return (Y);
}
public double Distance() //calculating distance
{
r = Math.Sqrt(X * X +Y * Y) ;
return (r);
}
}
}

Part 2 (Make button)


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

namespace earthmotion
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
double Xi = 1;
double Yi = 0;
double vxi = 0;
double vyi = 6.628;
double dt = 0.00002;

//double Xi = double.Parse(textBox1.Text);
//double Yi = double.Parse(textBox2.Text);
//double vxi = double.Parse(textBox3.Text);
//double vyi = double.Parse(textBox4.Text);
//double dt = double.Parse(textBox5.Text);

EarthMotion obj = new EarthMotion(Xi,Yi,vxi,vyi,dt);


while (true)
{
obj.Distance();
pictureBox2.Left=(int)(300+(obj.Xcompute())*250);
pictureBox2.Top=(int)(300-(obj.Ycompute())*250);
//Application.DoEvents();
//Thread.Sleep(1);
}
}
private void label7_Click(object sender, EventArgs e)
{

private void textBox1_TextChanged(object sender, EventArgs e)


{

}
}
}

You might also like