java - 在 android 中绘制从高度 X 掉落的球的高度与时间图

标签 java time graph height

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

到目前为止我所做的-------->>>>>>

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");
}

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

Ball dropped from a height (Graph plot)

最佳答案

https://github.com/Krish15595/TaskBouncingBall

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

关于java - 在 android 中绘制从高度 X 掉落的球的高度与时间图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60755542/

相关文章:

android - YYYYMMDDTHHMMSS 中的 T 是什么?

c++ - 复合模式中的内存管理

javascript - 无法使用ajax加载c3图形数据

java - 发布时未指定 gradle suproject 版本

java - 如何在某些测试中禁用 flapdoodle 嵌入式 mongodb

没有日期的 C++ 时间?

python - 在 Python 中调整日期时区的优雅方式

r - 如何从尼尔森输出图表?

java - JPanel repaint() 不工作

java - 调整 ElasticSearch 中的相关性