java在安卓中为从X高度落下的球绘制高度v/s时间图
我正在尝试构建一个应用程序,它显示所有高度和时间之间的图形,并显示反弹的总数,用户可以在其中输入高度,也可以更改系数强>
我到目前为止所做的----->&燃气轮机&燃气轮机&燃气轮机&燃气轮机&燃气轮机强>
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");
}
我想在下图的基础上绘制图表
任何帮助都将不胜感激,谢谢
# 1 楼答案
https://github.com/Krish15595/TaskBouncingBall
您使用的公式是错误的,使用androidchart库来显示线性图表