using System.Deployment.Application;
using System.Windows.Forms;
public class notEnoughInputException : Exception
public notEnoughInputException()
public notEnoughInputException(string message)
public notEnoughInputException(string message, Exception inner)
public double Hypot { get; set;}
public Angle Angle { get; set;}
public bool? yIsMoreX { get; set; }
private double _x { get; set;}
private double _y { get; set;}
public Triangle(double xl, double yl, double hypotenuse, double angl)
_x = -1; _y = -1; Hypot = -1;
if (this.Angle.Degrees == 0) { this.Angle.Degrees = findAngle(); }
if (this.Hypot == 0) { this.Hypot = findHypot(); }
if (this._y == 0) { _y = findYLeg(); }
if (this._x == 0) { _x = findXLeg(); }
private double findHypot()
if (X != 0 && Y != 0) return (Math.Sqrt((Math.Pow(X, 2) + Math.Pow(Y, 2))));
else if (((X == 0) || (Y == 0)) && Angle.Degrees != 0)
return (Y / Math.Sin(Angle.Radians));
else if (Y == 0 && X != 0)
return (X / Math.Cos(Angle.Radians));
private double findXLeg()
if (this.Y == 0 || this.Hypot == 0)
if (this.Angle.Degrees == 0) { throw new Exception("Cannot calculate thisngle angle, missing legs and angle."); }
var x = this.Angle.Quadrant;
else if (x == 10 || x == 6)
else if (x == 1 || x == 15)
return (this.Hypot * Math.Cos(this.Angle.Radians));
else if (x == 3 || x == 5)
return (this.Hypot * Math.Sin(this.Angle.Radians));
else if (x == 7 || x == 9)
return (-1 * (Math.Abs(this.Hypot * Math.Cos(this.Angle.Radians))));
else if (x == 11 || x == 14)
return (-1 * Math.Abs(this.Hypot * Math.Sin(this.Angle.Radians)));
else { return (Math.Pow(this.Hypot, 2) - Math.Pow(this.Y, 2)); }
private double findYLeg()
if (this.X == 0 || this.Hypot == 0)
if (this.Angle.Degrees == 0) { throw new Exception("Cannot calculate the X leg, missing input."); }
else if (x == 10 || x == 14)
else if (x == 1 || x == 7)
return (this.Hypot * Math.Sin(this.Angle.Radians));
else if (x == 3 || x == 5)
return (this.Hypot * Math.Cos(this.Angle.Radians));
else if (x == 9 || x == 15)
return (-1 * (this.Hypot * Math.Sin(this.Angle.Radians)));
else if (x == 11 || x == 14)
return (-1 * (Math.Abs(this.Hypot * Math.Sin(this.Angle.Radians))));
else { return (Math.Pow(this.Hypot, 2) - Math.Pow(this.Y, 2)); }
private double findAngle()
{ return (Angle.RadianToDegree(Math.Acos(this.Y / this.Hypot))); }
{ return (Angle.RadianToDegree(Math.Asin(this.X / this.Hypot))); }
else if (this.Hypot == 0)
{ return (Angle.RadianToDegree(Math.Atan(this.Y / this.X))); }
public Angle(double degrees)
_radians = DegreeToRadian(_degrees);
get { return _quadrant; }
private void findSubQuarter()
if (this.Degrees == 0 || this.Degrees == 360) _quadrant = 0;
else if (this.Degrees < 45 && this.Degrees > 0) _quadrant = 1;
else if (this.Degrees == 45) _quadrant = 2;
else if (this.Degrees > 45 && this.Degrees < 90) _quadrant = 3;
else if (this.Degrees == 90) _quadrant = 4;
else if (this.Degrees > 90 && this.Degrees < 135) _quadrant = 5;
else if (this.Degrees == 135) _quadrant = 6;
else if (this.Degrees > 135 && this.Degrees < 180) _quadrant = 7;
else if (this.Degrees == 180) _quadrant = 8;
else if (this.Degrees > 180 && this.Degrees < 225) _quadrant = 9;
else if (this.Degrees == 225) _quadrant = 10;
else if (this.Degrees > 225 && this.Degrees < 270) _quadrant = 11;
else if (this.Degrees == 270) _quadrant = 12;
else if (this.Degrees > 270 && this.Degrees < 315) _quadrant = 13;
else if (this.Degrees == 315) _quadrant = 14;
else if (this.Degrees > 315 && this.Degrees < 360) _quadrant = 15;
public static double DegreeToRadian(double angle)
return (( angle) / 180.0);
public static double RadianToDegree(double angle)
return ((180 / Math.PI) * angle);
public double? Xi { get; set; }
public double? Xf { get; set; }
public double? Vi_x { get; set; }
public double? Vf_x { get; set; }
public double? Ax { get; set; }
public double? Tx { get; set; }
public double Yi { get; set; }
public double Yf { get; set; }
public double Vi_y { get; set; }
public double Vf_y { get; set; }
public double Ay { get; set; }
public double Ty { get; set; }
public double Zi { get; set; }
public double Zf { get; set; }
public double? Vi_z { get; set; }
public double? Vf_z { get; set; }
public double Az { get; set; }
public double? Tz { get; set; }
public Angle Elevation { get; set; }
public Angle Azimuth { get; set; }
{ get { return _dims; } }
public partial class frmMain : Form
public string CurrentVersion
return ApplicationDeployment.IsNetworkDeployed
? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
: Assembly.GetExecutingAssembly().GetName().Version.ToString();
public maths _maths = new maths();
private void btnKinematics_Click(object sender, EventArgs e)
kinematics _kinematics = new kinematics(this);
private void btnTrig_Click(object sender, EventArgs e)
var trig = new trig(this);
private void btnProjectile_Click(object sender, EventArgs e)
public partial class kinematics : Form
decimal?[,] input = new decimal?[2,6];
TextBox[,] txtArray = new TextBox[2, 6];
CheckBox[,] chkArray = new CheckBox[2, 6];
public kinematics(frmMain _form)
if (chkY.Checked == true)
for (int ia = 0; ia <= 1; ia++)
for (int ib = 0; ib <= 5; ib++)
if (chkArray[ia, ib].Checked == true)
txtArray[ia, ib].BackColor = Color.DarkGray;
txtArray[ia, ib].BackColor = Color.White;
input[ia, ib] = Convert.ToDecimal(txtArray[ia, ib].Text.Trim());
for (int ib = 0; ib <= 5; ib++)
if (chkArray[0, ib].Checked == true)
txtArray[0, ib].BackColor = Color.DarkGray;
txtArray[0, ib].BackColor = Color.White;
input[0, ib] = Convert.ToDecimal(txtArray[0, ib].Text.Trim());
private void showOutput(decimal[,] output)
for (int ia = 0; ia <= 1; ia++)
for (int ib = 0; ib <= 5; ib++)
txtArray[ia, ib].Text = output[ia, ib].ToString();
private void btnCalc_Click(object sender, EventArgs e)
decimal[,] _result = _frmMain._maths.findKinematics(input);
private void kinematics_Load(object sender, EventArgs e)
txtArray[0, 0] = this.txtXi; txtArray[0, 1] = this.txtXf;
txtArray[0, 2] = this.txtXVi; txtArray[0, 3] = this.txtXVf;
txtArray[0, 4] = this.txtXacc; txtArray[0, 5] = this.txtT;
txtArray[1, 0] = this.txtYi; txtArray[1, 1] = this.txtYf;
txtArray[1, 2] = this.txtYVi; txtArray[1, 3] = this.txtYVf;
txtArray[1, 4] = this.txtYacc; txtArray[1, 5] = this.txtT;
chkArray[0, 0] = this.chkXi; chkArray[0, 1] = this.chkXf;
chkArray[0, 2] = this.chkXVi; chkArray[0, 3] = this.chkXVf;
chkArray[0, 4] = this.chkXacc; chkArray[0, 5] = this.chkT;
chkArray[1, 0] = this.chkYi; chkArray[1, 1] = this.chkYf;
chkArray[1, 2] = this.chkYVi; chkArray[1, 3] = this.chkYVf;
chkArray[1, 4] = this.chkYacc; chkArray[1, 5] = this.chkT;