【问题标题】:Plot a height v/s time graph in android for ball dropped from a height X在android中为从高度X落下的球绘制高度v/s时间图
【发布时间】:2020-06-30 11:47:52
【问题描述】:

我正在尝试构建一个应用程序,它显示所有高度和时间之间的图表并显示弹跳总数,其中高度可以由用户输入,系数也可以更改。

到目前为止我做了什么------->>>>>>

LineGraphSeries<DataPoint> series;
double start_height = 20.0;
double x, y = 0.0;
double time = 0.0;
double velocity = 0.0;

double gravity = 10.0;
double step = 0.1;
//v=u+at
double h = 0.0;
double reachesGround = 0.0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    GraphView graphView = findViewById(R.id.graphView);
    series = new LineGraphSeries<>();


    velocity = Math.sqrt(2*gravity*start_height);
    reachesGround = velocity/gravity;

    for (double i = start_height; i > 0.0; i--){
        //Time
        x += 0.1;
        //calculate next height to which the ball bounces
        y = i - ((10/100)*i);

        series.appendData(new DataPoint(x, y), true, (int) reachesGround);
    }

    graphView.addSeries(series);
    graphView.setTitle("Height v/s time graph");
}

我想根据下图绘制图表
任何帮助将不胜感激,谢谢。

【问题讨论】:

    标签: java time graph height


    【解决方案1】:

    https://github.com/Krish15595/TaskBouncingBall

    你使用的公式是错误的,使用androidchart库来显示线性图表

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多