yonimal676 / basketball Goto Github PK
View Code? Open in Web Editor NEWAndroid project that includes projectile motion written in Java
Android project that includes projectile motion written in Java
level of difficulty: 3/5
Here is a general representation of the problem:
Originally posted by yonimal676 October 11, 2022
great visualizer:
https://ophysics.com/k8.html
FEATURE:
public void physicsUpdateNoCol(float time)
most of the times, the time parameter is going to be ball.time, how ever I will add this parameter in case i want to calculate the next X/Y.
This happens when the ball is shot at the approximate angle of -177 degrees
previously it looked like this:
with this formula (v0y is minus because of the inverted Y axis):
ball.vy = - ball.v0y - (ball.GRAVITY * time);
but now the code is:
if (quarterOfLaunch == 1 || quarterOfLaunch == 2) // throwing the ball downwards.
ball.vy = ball.v0y - (ball.GRAVITY * time); // the vertical velocity changes constantly.
else
ball.vy = ball.v0y + (ball.GRAVITY * time);
After playing with the physics for a bit, this is the current state:
There are 3 types of collisions:
premise:
Attributes:
premise:
premise:
where do i even start??
This problem is caused from the velocityX being impossibly tiny (7.717558E-5 for example).
so one solution might be setting velocityX to 0 AS IT SHOULD BE when the angle is 90 or -90.
Found the source of the bug:
if (ball.velocityY == 0 || ball.x >= ball.range * ball.ratioPXtoM)
ball.velocityY *= -1;
To be honest i have no idea why it was there in the first place, but that happens sometimes...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.