コード例 #1
0
 public double CalculTrajectoire(Objets obj, double x)
 {
     /*return ScientWrite.fromScient(ScientWrite.mult(ScientWrite.toScient(Math.Tan(DegToRad(angle))),ScientWrite.toScient(x)))
      + obj.getPosY0()
      +     - ScientWrite.fromScient(ScientWrite.mult(ScientWrite.toScient(gravity * x * x),
      +         ScientWrite.toScient(2 * vit0 * vit0*Math.Pow(Math.Cos(DegToRad(angle)),2))));
      */
     return(Math.Tan(DegToRad(angle)) * x + obj.getPosY0() - ((gravity * x * x) / (2 * vit0 * vit0 * Math.Pow(Math.Cos(DegToRad(angle)), 2))));
 }
コード例 #2
0
        private void Event_Launcher(object sender, MouseEventArgs e)
        {
            int i = 0;

            MessageBox.Show((agrandissement + 1) + "");
            courbe = new Point[graph.Width / agrandissement + 1];
            while (obj_tennis.getPosY() > 0)
            {
                but_tennis.Location = new Point((int)(graph.Location.X + obj_tennis.getPosX() * agrandissement), (int)(graph.Location.Y + graph.Height - obj_tennis.getPosY() * agrandissement));
                courbe[i]           = new Point(but_tennis.Location.X - graph.Location.X, but_tennis.Location.Y - graph.Location.Y);
                i++;
                obj_tennis.setPosX(obj_tennis.getPosX() + 1);
                obj_tennis.setPosY(envi.CalculTrajectoire(obj_tennis, obj_tennis.getPosX()));
            }
            double lastX = Solve(-(envi.getGravity() / (2 * Math.Pow(envi.getVit0(), 2) * Math.Pow(Math.Cos(envi.DegToRad(envi.getAngle())), 2))), Math.Tan(envi.DegToRad(envi.getAngle())), obj_tennis.getPosY0())[0];

            obj_tennis.setPosX(lastX);
            but_tennis.Location = new Point((int)(graph.Location.X + obj_tennis.getPosX() * agrandissement), graph.Location.Y + graph.Height - but_tennis.Height);
            courbe[i]           = new Point(but_tennis.Location.X - graph.Location.X, but_tennis.Location.Y - graph.Location.Y + but_tennis.Height);
            Array.Resize(ref courbe, i + 1);
            if ((this.Width - 10) / agrandissement > courbe.Length)
            {
                print_Courbe(1, 0, courbe.Length - 1);
            }
            else
            {
                print_Courbe(1, 0, (this.Width - 10) / agrandissement);
            }
            launch.MouseClick -= Event_Launcher;
        }