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

Started by
2 comments, last by Paradigm Shifter 10 years, 3 months ago

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.

Please help me. Thank you very much in advance.

Advertisement
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

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?

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.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

This topic is closed to new replies.

Advertisement