Sign in to follow this  
beachbump

Picking points on a 5 pointed start uniformly at random

Recommended Posts

I am implementing some fireworks in opengl. I would like to have to cool firework effects. Right now all i have is when the rockets explode, then send sparks flying in random directions that are basically chosen by picking random points on a sphere. I would like to have a 2D star pattern though I am not sure how to pick points uniformly at random on a star. Any ideas?

Share this post


Link to post
Share on other sites
Pick uniform random samples of the direction you want to go (from 0-2 pi), then, initialize the direction vector of the velocity to that direction. Next, compute the equation of a star in polar coordinates, and set the velocity magnitude equal to that direction. For example, the equation of

Share this post


Link to post
Share on other sites
Construct 10 line vectors that form the star shape. For each of the 10 lines on the star roll a fixed or random amount of numbers between 0 and the length of the line and use the line vectors to calculate destination points for the sparks. You could also move the destination points outwards or inwards along the normal of the line for some more randomness.

[Edit] Were you talking about a filled star or just the outline of a star? My suggested method is for the latter.

[Edited by - Mussi on December 11, 2010 8:17:55 AM]

Share this post


Link to post
Share on other sites

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