Jump to content
  • Advertisement
Sign in to follow this  
MaimaVanPersie

Calculate position and angle of javelin exercise (my attempt)

This topic is 475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement

Heya. 

I think you should read the question more carefully as you seem to have a mismatch in your attempt. The question says that your function should return a vector, which is something you're not doing. Also your function is taking in 4 arguments and the exercise is saying to compute using but three floats. With that said, you seem to be adding angle + distance^2 which I don't think is correct. You should probably look more into kinematic equations before you attempt this again. I recommend visiting this site (http://www.physicsclassroom.com/) and going through the first sections so you may have a better understanding of the motion of objects in 2D space. 

 

Good job on attempting the exercise though. :)  

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!