我的弹射器游戏产生的距离不正确

Incorrect distance being produced by my catapult game

我的弹射器游戏中似乎有一个涉及距离方程的严重问题。该方程旨在计算弹射器以给定速度和发射角度发射的射弹的距离。通常距离总是高得离谱。

速度是根据特定的用户输入密度计算的,因此也可能存在问题。我禁用了角度有效性检查并将触发角度设置为 90(这不会给我 0 距离)并且我得到了相当高的数字。

我无法验证导致程序出现问题的原因,因为我不学习物理,而且我知道方程式中的任何错误(我们的老师向我们提供了公式)。我想知道是否有任何精通物理的程序员可以帮助我修复这个游戏?

P.S。我认为问题可能是由我的弧度转换引起的。这是我的代码片段:

          cout << "Choose a material to launch:" << endl
               << "1) BIRCH WOOD (670 kg/m^3)\n2) ICE (917 kg/m^3)\n3) FLAMING COAL (1500 kg/m^3)\n4) ASBESTOS (2450 kg/m^3)" << endl;
          cin  >> materialChoice;
          materialChoice = int(materialChoice);
          while (materialChoice < 1 || materialChoice > 4)
          {
                cout << "Please choose a valid material type:" << endl
                     << "1) BIRCH WOOD (670 kg/m^3)\n2) ICE (917 kg/m^3) 3) FLAMING COAL (1500 kg/m^3)\n4) ASBESTOS (2450 kg/m^3)" << endl;
                cin  >> materialChoice;
                materialChoice = int(materialChoice);
          }

          switch (materialChoice)
          {
          case 1:
               density = 670;
               break;
          case 2:
               density = 917;
               break;
          case 3:
               density = 1500;
               break;
          default: 
               density = 2450;
          }

          cout << "Now select a launch angle between 20 and 70 degrees:" << endl;
          cin  >> angleChoice;

          while (angleChoice < 20 || angleChoice > 70)
          {
              cout << "Please select a valid launch angle between 20 and 70 degrees:" << endl;
              cin  >> angleChoice;
          }    

          cout << "Now select the radius of the projectile between 6 cm and 10 cm:" << endl;
          cin  >> radius;
          while (radius < 6 || radius > 10)
          {
                cout << "Please select a valid radius for the projectile between 6 cm and 10 cm:" << endl;
                cin  >> radius;
          } 
          velocity = 360000.0/(density * radius);
          distance = 2 * sin(RADIAN * (angleChoice)) * velocity * cos(RADIAN * (angleChoice)) * velocity/9.8;

          cout << "The projectile goes flying! Press any number to check where it landed" << endl;
          cin  >> null;
          shortDiff = (abs(distance - 24));

RADIAN 的值应该是 PI/180
(PI radian)/(180 degrees)*(ANGLE in degrees) 将以 RADIAN 为单位给出结果。
进行更改,然后根据需要进行调试。