Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How do I randomize points within a certain area using Processing.?

Okay, so I have to do this project for my Computer Science class, and we are doing random() in Processing. What I want to do is to create an atom-like structure by putting a little circle at the center (nucleus) of the page, and to make two bigger circles around it, in which the area between them is where electrons would be randomized. I attached a terrible looking picture to roughly estimate what I'd like it to look like. As you can see, the nucleus is in the center, and then there are two circles. All of the area between those circles I would like to have a point randomly popping into that area using the random function.

The only thing I could possibly think of is using equations of circles, maybe inequalities, to set the parameters.

Anything would be appreciated, because I'm beat. I have no idea how to go about this.

Attachment image

1 Answer

Relevance
  • ?
    Lv 7
    8 years ago
    Favorite Answer

    Use polar coordinates.

    http://en.wikipedia.org/wiki/Polar_coordinate

    That means that you'll have two random values - the angle theta, and the length r from the center. You'll have to add a constant, which would be the inner circle, in order to not get any points there. You could then convert this to an orthogonal XY coordinate if you wish.

Still have questions? Get your answers by asking now.