private void DrawVelocityY(double time, Cannonball obj, double vx) { double vy; for (double i = 0.0; i <= time; i += 0.01) { vy = obj.VelocityY(i); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(i).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); panel1.Refresh(); } }
private void DrawVelocityY(double time, Cannonball obj, double vx, bool flag, double alcance, double alturaMax) { double vy = 0; Image img = Properties.Resources.pointXY; Image imgBall = Properties.Resources.ballfinal; int comprimento, largura, escalax, escalay, pwidth = 3, pheight = 3; comprimento = pnlGraphic.Size.Width - 25; //25 largura = pnlGraphic.Size.Height - 25; //25 escalax = ((int)alcance / comprimento); escalay = ((int)alturaMax / largura); //g.TranslateTransform(0.0F, -(float)Height); //comprimento_imagem = imgCannon.Size.Width-73; //largura_imagem = imgCannon.Size.Height-150; //largura_imagem = pnlGraphic.Size.Height; //MessageBox.Show("altura" + largura_imagem.ToString()); //g.TranslateTransform(0.0F, -(float)524); pnlGraphic.Refresh(); if (comprimento < alcance && largura < alturaMax) { graphicsObj.DrawImage(cannonImg, 0, 550); g2.DrawImage(img, (int)(obj.X / (escalax * 2)), (int)(obj.Y / (escalay * 2))); //g2.DrawIcon(Properties.Resources.ball,(int) (obj.X / (escalax * 2)),(int) (obj.Y / (escalay * 2))); //g2.DrawEllipse(p2, ((float)obj.X/ (escalax * 2)), ((float)obj.Y / (escalay * 2)), pwidth, pheight); for (double i = 0.00; i <= time + 1; i += 0.1) { if (i >= time) { vy = obj.VelocityY(time); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(time).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(time).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(time).ToString("0.##")); //g.DrawEllipse(p, ((float)obj.getXLocation(i)) / escalax, ((float)obj.getYLocation(i) + 440) / escalay, 3, 3); //panel1.Refresh(); } else { vy = obj.VelocityY(i); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(i).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(i).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(i).ToString("0.##")); labelgetX.Text = String.Format("{0} m", obj.X.ToString()); labelgetY.Text = String.Format("{0} m", obj.Y.ToString()); labelXuser.Text = String.Format("1:{0}", (escalax * 2).ToString("0.##")); labelYuser.Text = String.Format("1:{0}", (escalay * 2).ToString("0.##")); if (obj.getXLocation(i) / (escalax * 2) < 33 && (obj.getYLocation(i)) < 33) { } else { pnlGraphic.Refresh(); graphicsObj.DrawImage(cannonImg, 0, 554); g2.DrawImage(img, (int)(obj.X / (escalax * 2)), (int)(obj.Y / (escalay * 2))); g2.DrawImage(imgBall, (int)(obj.getXLocation(i) - 200 / (escalax * 2)), (int)(obj.getYLocation(i) / (escalay * 2))); //g.DrawImage(img, (int)(obj.getXLocation(i) - 200 / (escalax * 2)), (int)(obj.getYLocation(i) / (escalay * 2))); } //g.DrawIcon(Properties.Resources.ball, (int)(obj.getXLocation(i) / (escalax * 2)), (int)(obj.getYLocation(i) / (escalay * 2))); //g.DrawEllipse(p, ((float)obj.getXLocation(i) / (escalax * 2)), ((float)obj.getYLocation(i) / (escalay * 2)), pwidth, pheight); //panel4.Refresh(); } panel1.Refresh(); } } else if (comprimento < alcance && largura > alturaMax) { graphicsObj.DrawImage(cannonImg, 0, 554); g2.DrawImage(img, (int)(obj.X / (escalax * 2)) + 10, (int)(obj.Y)); g2.DrawImage(imgBall, 28, 28); //g2.DrawIcon(Properties.Resources.ball, (int)(obj.X / (escalax * 2)), (int)(obj.Y)); //g2.DrawEllipse(p2, ((float)obj.X) / (escalax*2), ((float)obj.Y), pwidth, pheight); for (double i = 0.00; i <= time + 1; i += 0.1) { if (i >= time) { vy = obj.VelocityY(time); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(time).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(time).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(time).ToString("0.##")); // g.DrawEllipse(p, ((float)obj.getXLocation(i)) / escalax, ((float)obj.getYLocation(i) + 440), 3, 3); //panel1.Refresh(); } else { vy = obj.VelocityY(i); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(i).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(i).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(i).ToString("0.##")); if (obj.getXLocation(i) / (escalax * 2) < 33 && (obj.getYLocation(i)) < 33) { } else { pnlGraphic.Refresh(); graphicsObj.DrawImage(cannonImg, 0, 554); g2.DrawImage(img, (int)(obj.X / (escalax * 2)) + 10, (int)(obj.Y)); g2.DrawImage(imgBall, (int)(obj.getXLocation(i) / (escalax * 2)) + 10, (int)(obj.getYLocation(i))); //g.DrawImage(img, (int)(obj.getXLocation(i) / (escalax * 2)) + 10, (int)(obj.getYLocation(i))); } //g.DrawIcon(Properties.Resources.ball, (int)(obj.getXLocation(i) / (escalax * 2)), (int)(obj.getYLocation(i))); //g.DrawEllipse(p, ((float)obj.getXLocation(i) / (escalax*2)), ((float)obj.getYLocation(i)), pwidth, pheight); labelgetX.Text = String.Format("{0} m", obj.X.ToString()); labelgetY.Text = String.Format("{0} m", obj.Y.ToString()); labelXuser.Text = String.Format("1:{0}", (escalax * 2).ToString("0.##")); //labelXuser.Text = "0"; //panel4.Refresh(); } panel1.Refresh(); } } else if (comprimento > alcance && largura < alturaMax) { graphicsObj.DrawImage(cannonImg, 0, 554); g2.DrawImage(img, (int)(obj.X), (int)(obj.Y / (escalay * 2))); //g2.DrawIcon(Properties.Resources.ball, (int)(obj.X), (int)(obj.Y / (escalay * 2))); //g2.DrawEllipse(p2, ((float)obj.X), ((float)obj.Y) / (escalay*2), pwidth, pheight); for (double i = 0.00; i <= time + 1; i += 0.1) { if (i >= time) { vy = obj.VelocityY(time); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(time).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(time).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(time).ToString("0.##")); //g.DrawEllipse(p, ((float)obj.getXLocation(i)), ((float)obj.getYLocation(i) + 440) / escalay, 3, 3); panel1.Refresh(); } else { vy = obj.VelocityY(i); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(i).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(i).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(i).ToString("0.##")); if (obj.getXLocation(i) / (escalax * 2) < 33 && (obj.getYLocation(i)) < 33) { } else { pnlGraphic.Refresh(); graphicsObj.DrawImage(cannonImg, 0, 554); g2.DrawImage(img, (int)(obj.X), (int)(obj.Y / (escalay * 2))); g2.DrawImage(imgBall, (int)(obj.getXLocation(i)), (int)(obj.getYLocation(i) / (escalay * 2))); //g.DrawImage(img, (int)(obj.getXLocation(i)), (int)(obj.getYLocation(i) / (escalay * 2))); } //g.DrawIcon(Properties.Resources.ball, (int)(obj.getXLocation(i)), (int)(obj.getYLocation(i) / (escalay * 2))); //g.DrawEllipse(p, ((float)obj.getXLocation(i)), ((float)obj.getYLocation(i)) / (escalay*2), pwidth, pheight); labelgetX.Text = String.Format("{0} m", obj.X.ToString()); labelgetY.Text = String.Format("{0} m", obj.Y.ToString()); //labelXuser.Text = "0"; labelYuser.Text = String.Format("1:{0}", (escalay * 2).ToString("0.##")); //panel4.Refresh(); } panel4.Refresh(); } } else { graphicsObj.DrawImage(cannonImg, 0, 554); g2.DrawImage(img, (int)(obj.X), (int)(obj.Y)); //g2.DrawIcon(Properties.Resources.ball, (int)(obj.X), (int)(obj.Y)); //g2.DrawEllipse(p2, ((float)obj.X), ((float)obj.Y), pwidth, pheight); for (double i = 0.00; i <= time + 1; i += 0.1) { if (i >= time) { vy = obj.VelocityY(time); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(time).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(time).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(time).ToString("0.##")); // g.DrawEllipse(p, ((float)obj.getXLocation(i)), ((float)obj.getYLocation(i) + 440), 3, 3); panel1.Refresh(); } else { vy = obj.VelocityY(i); lblResultY.Text = String.Format("{0} m/s", obj.VelocityY(i).ToString("0.##")); lbVelToatal.Text = String.Format("{0} m/s", obj.VelocityTotal(vx, vy).ToString("0.##")); lbMostraPosx.Text = String.Format("{0} m", obj.getXLocation(i).ToString("0.##")); lbMostraPosy.Text = String.Format("{0} m", obj.getYLocation(i).ToString("0.##")); if (obj.getXLocation(i) < 40 && obj.getYLocation(i) < 40) { } else { pnlGraphic.Refresh(); graphicsObj.DrawImage(cannonImg, 0, 554); g2.DrawImage(img, (int)(obj.X), (int)(obj.Y)); g2.DrawImage(imgBall, (int)(obj.getXLocation(i)), (int)(obj.getYLocation(i))); //g.DrawImage(img, (int)(obj.getXLocation(i)), (int)(obj.getYLocation(i))); } //g.DrawIcon(Properties.Resources.ball, (int)(obj.getXLocation(i)), (int)(obj.getYLocation(i))); //g.DrawEllipse(p, ((float)obj.getXLocation(i)), ((float)obj.getYLocation(i)), pwidth, pheight); labelgetX.Text = String.Format("{0} m", obj.X.ToString()); labelgetY.Text = String.Format("{0} m", obj.Y.ToString()); labelXuser.Text = "0"; labelYuser.Text = "0"; //panel4.Refresh(); } panel1.Refresh(); } panel1.Refresh(); } panel1.Refresh(); }