Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Calculate position and angle of javelin exercise (my attempt)

$
0
0
Hello everybody, I am self-teaching myself game physics and currently I am reading a book called "Mathematics and Physics for game programmers" and I am at chapter 7 exercise 1 where one of the exercises ask:Write a function javelin(throwAngle, throwSpeed, time) which calculates the position and angle of a javelin over time. The function should return a vector representing the position of the javelin at time time after firing and the angle it makes with the horizontal. During its flight, a javelin is more or less oriented along the tangent to the curve—that is to say, parallel to the velocity vector After giving it a go, this is what I managed to come up with: float Javelin(float ThrowAngle, float Velocity, float Acceleration, float Time) { return ThrowAngle + Velocity * Time + Acceleration * Time * Time / 2.0f; } The function above is meant to return the position of the javelin after the throw, but I am not sure whether it is correct or not because the book does not contain the solution to this exercise (hence why I am posting). Do you think this looks alright? And if so, how can I obtain the angle?Thank you so much for your help.

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>