Ejemplo n.º 1
0
        public int Agrandissement(int sizeObj, Objets obj, Label graph)
        {
            double x    = 0;
            double c    = CalculTrajectoire(obj, x);
            double ymax = c;

            while (c > 0)
            {
                x++;
                c    = CalculTrajectoire(obj, x);
                ymax = Math.Max(ymax, c);
            }

            int agx = (int)((graph.Width - sizeObj) / x);

            if (agx == 0)
            {
                return(-1);
            }
            while (ymax * agx > graph.Height)
            {
                agx /= 2;
            }

            if (agx == 0)
            {
                return(-2);
            }

            return(agx);
        }
Ejemplo n.º 2
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))));
 }
Ejemplo n.º 3
0
        public void Restart(double masse, double gravity, double speed, double angle, double posY0)
        {
            ctrl   = true;
            courbe = null;
            Controls.Clear();
            graph          = buildLabel();
            envi           = new Environnement(gravity, speed, angle);
            obj_tennis     = new Objets(masse, posY0);
            sizeFirstMenu  = 1000;
            agrandissement = envi.Agrandissement(10, obj_tennis, graph);
            while (agrandissement == -1)
            {
                graph.Width    = (int)(graph.Width * 2);
                agrandissement = envi.Agrandissement(10, obj_tennis, graph);
            }
            while (agrandissement == -2)
            {
                graph.Height   = (int)(graph.Height * 1.2);
                agrandissement = envi.Agrandissement(10, obj_tennis, graph);
            }
            but_tennis      = buttonGenerator(graph.Location.X, (int)(graph.Location.Y + (graph.Height) - agrandissement * obj_tennis.getPosY()));
            but_tennis.Size = new Size(10, 10);

            infos          = buildLabel();
            infos.Size     = new Size((sizeFirstMenu - 20) / 3, 60);
            infos.Location = new Point(10, 10);
            infos.Text     = "Mass: " + obj_tennis.getMasse() + "\nSpeed: " + envi.getVit0() + "\nAngle: " +
                             envi.getAngle() + "\nGravity: " + envi.getGravity();

            launch      = buttonGenerator((20 + (sizeFirstMenu - 20) / 3), 10);
            launch.Text = "Launch";

            restart      = buttonGenerator(10 + 2 * (10 + (sizeFirstMenu - 20) / 3), 10);
            restart.Text = "Restart";

            but_tennis.MouseClick += new MouseEventHandler(ButtonPosTraject);
            launch.MouseClick     += new MouseEventHandler(Event_Launcher);

            restart.MouseClick += new MouseEventHandler(EventRestart);
            graph.Paint        += buildAxes;

            graph.MouseClick += new MouseEventHandler(MousePos);
            this.Scroll      += panel1_Scroll;

            this.KeyPreview = true;
            this.KeyDown   += new KeyEventHandler(On_CTRL);
            this.KeyUp     += new KeyEventHandler(Off_CTRL);
        }