I am writing a game in Javascript, and I just got a big math problem, where $\text{friction} = 0.97$.
This is what is being looped every $1000$ / $60$ milliseconds, to make the projectile move all the time, also it applies friction:
{
proj.vx = proj.vx * friction
proj.vy = proj.vy * friction
proj.x = proj.x + proj.vx
proj.y = proj.y + proj.vy
}
Then firstly when the projectile is being created, the problem comes: The projectile starts at $x =20, y= 10$:
{
proj = new Object()
proj.x = 20
proj.y = 10
speed = ???????? <--- Here is the problem
proj.vx = cos(atan2(10-80, 20-60)) * speed
proj.vy = sin(atan2(10-80, 20-60)) * speed
}
Now we are at the problem, I want the projectile to stop at a specific position, let's say it is $x =60$ and $y =80$. How do I calculate what speed it should be if I want the projectile to stop at that specific spot? What is the equation?
As an answer to JMCF125 (could not comment, on mobile glitched): well the game is 2d based, so you see the world from upwards, then you cant see if an object is on a specific height, ok i think it was because i called the object a projectile, but lets call it a curling stone because that is exactly what it is most simililar too in this case, sry 4 bad english , there is no floor in programming, you have to make the game's floor look and act like a floor thats how, and it is not a random, point, it is fully specified that it should stop at x = 60, y = 80, ik it sounds unreal, but this is not real, this is just a game, plz tell me you understand what the problem is, thanks btw to you and the coming solver and yes im doing it without gravity. odd is odd, but everything seems odd from odd eyes. are you a programmer? if not it might be even more confusing, but i hope you can understand anyways. reason why i asked this here and not on stackoverflow or gamedev is because this is really advanced ok sure not for all but for the most and me
Answer I just found:
speed = (1 / friction - 1) * sqrt((20 - 60)^2 + (10 - 80)^2)