# Picking points on a 5 pointed start uniformly at random

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

## 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 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 on other sites
Or instead, generate random points that are within the bounding box and discard (i.e. reroll) any that fall outside the star.

##### 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.

 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 on other sites
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.

##### Share on other sites
Edit: my post was basically a repost of what samoth said.

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

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 16
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632928
• Total Posts
3009264
• ### Who's Online (See full list)

There are no registered users currently online

×