Sign in to follow this  

3d - projectile from point A to point B

This topic is 4587 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 - In my 3D game, I want to fire a projectile (a slow-moving ball of energy) from a ship sitting at Vector A, and I want it to travel a distance of D units, then stop (explode). For direction, I know the Yaw and Pitch of the ship, expressed in degrees. No gravity, no outside forces, just a straight line through 3D space. I thought that I knew enough about vector math to handle this, but I am having trouble. Can someone help get me on track? Thanks in advance!

Share this post


Link to post
Share on other sites
If the ship only yaws (about the world up axis) and pitches (about the local side axis) you can use spherical coordinates to find the direction vector. There are different ways to do the spherical-to-cartesian conversion depending on which axis is up and which is forward, and which direction the side vector points. So don't expect equations you find online to necessarily work as is; you may have to adapt them to your needs.

Alternately, you could do it with Euler angles. Create a matrix for yaw around world up and a matrix for pitch around the world side vector. Then, if you're using column vectors:

M = yaw * pitch;

Row vectors:

M = pitch * yaw;

The forward vector can then be extracted from M. Plus, you have the rotation matrix available for other purposes if you need it.

Share this post


Link to post
Share on other sites

This topic is 4587 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this