Jump to content
  • Advertisement
Sign in to follow this  
BlurEffect

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.

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

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.

Please help me. Thank you very much in advance.

Share this post


Link to post
Share on other sites
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
Edited by Álvaro

Share this post


Link to post
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 this post


Link to post
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.

Edited by Paradigm Shifter

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!