# Calculate velocity of subparticles from a main projectile and a launch angle

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

## Recommended Posts

Hey guys,

I have to create a firework using particle systems in DirectX 9 but the math/physics stuff is killing me. I've been fiddling around with this for hours and couldn't get it to work as I want it to, which is why I'm now asking here.

I have a projectile flying physically correct that will burst into smaller particles after some time. I want the particles to be dispersed in a cone-like shape defined by the direction of the original projectile and an angle alpha, that are both known. I tried to make a little sketch of what I want to achieve but if you need clarification, feel free to ask.

[attachment=19401:Projectile.png]

I have to determine the velocity/flying direction for the particles. As I said, I know the original projectile's velocity/direction and the angle of the cone but I don't know how to combine these two to achieve what I want.

##### Share on other sites
subparticle_velocity.x = cos(alpha) * projectile_velocity.x - sin(alpha) * projectile_velocity.y;
subparticle_velocity.y = sin(alpha) * projectile_velocity.x + cos(alpha) * projectile_velocity.y;

Or, with complex numbers representing velocities and "angle alpha" represented as (cos(alpha) + sin(alpha)*i),
 subparticle_velocity = projectile_velocity * rotation
Edited by Álvaro

##### Share on other sites

Thank you very much for your anwer, I will test it soon. Given a 3d space (including a z-component of the velocity) would it be possible to calculate the subparticle velocity in a similar fashion?

##### Share on other sites

Pick a random vector inside a cone that is axis aligned (e.g. tip of cone at (0, 0, 1), centre of base (0, 0, 0)), then scale and rotate it into the correct orientation using either a matrix or quaternion is probably the easiest way to do it in 3d.

EDIT: You can pick lots of vectors from inside the cone and rotate them all with the same matrix is the reason I would do it that way.

EDIT2: It's probably easier to have the tip of the cone at the origin instead, then you can just pick a random ray from the origin within the cone half angle.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 12
• 9
• 9
• 25