Picking points on a 5 pointed start uniformly at random

Started by
3 comments, last by Maze Master 13 years, 4 months ago
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?
Advertisement
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
Or instead, generate random points that are within the bounding box and discard (i.e. reroll) any that fall outside the star.
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]
Build your star out of 10 congruent triangles. Pick a random triangle first, then pick a random point in the triangle.

I have other alternatives, but I think that's the best one.
Edit: my post was basically a repost of what samoth said.

[Edited by - Maze Master on December 11, 2010 7:39:57 PM]

This topic is closed to new replies.

Advertisement