# How to generate points/ellipse within a circle area

**URL:** <https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933>\
**Category:** Coding Questions\
**Created:** [May 16, 2020, 6:47am UTC](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933 "2020-05-16T06:47:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuinjann](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yuinjann](https://discourse.processing.org/u/yuinjann)\
**Post date:** [May 16, 2020, 6:47am UTC](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933/1 "2020-05-16T06:47:46Z")

</div>

Hello! I’m trying to generate ellipses within an ellipse, or a circular area.  
for example:

```auto
for (let i=0; i< 100; i++){
ellipse (random(width), random(height), 10)
}
noLoop();

```

Is there a way to generate these random circles within an ellipse instead of the canvas? I’ve looked at drawing circles along a circle, but I want it to be within it too. I’ve also looked at circle packing, but I don’t think it needs to be that complicated, I just need to generate points within a circle

Let me know, thank you!

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 16, 2020, 7:27am UTC](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933/2 "2020-05-16T07:27:49Z")

</div>

Hello!

You can check the distance to the middle of the circle. Only draw the random point when the distance is `<radius`.

- Use `if(...)` and `dist()` - see reference.

The other way is to use cos and sin to calculate a position inside the circle.

- See website, tutorials, trigonometry please. Together with a random radius and random angle (0…TWO\_PI).

Warmest regards

Chrisir

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 16, 2020, 4:15pm UTC](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933/3 "2020-05-16T16:15:09Z")

</div>

Hello,

> **Resources \< Click here to expand !**
>
> I encourage you to review the resources available here:
> 
> - The Processing website has references, examples, tutorials, etc.  
> [https://processing.org/](https://processing.org/)
> - Those available with the Processing PDE (IDE).  
> An exploration of the tabs will reveal what is available; there are libraries and examples there.
> - The Coding Train  
> [https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
> [https://thecodingtrain.com/](https://thecodingtrain.com/)
> - Happy Coding  
> [Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)
> - The Processing Foundation  
> [https://processingfoundation.org/](https://processingfoundation.org/)  
> Check out the tabs.  
> In the education tab, there is a reference to the Coding Train.

`:)`

---

<div class="post-metadata">

**Author:** ![yuinjann](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yuinjann](https://discourse.processing.org/u/yuinjann)\
**Post date:** [May 17, 2020, 6:10pm UTC](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933/4 "2020-05-17T18:10:59Z")

</div>

thank you both so much! yeah that makes so much sense, will try it out 🙂

---

<div class="post-metadata">

**Author:** ![ProcessingOrg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/processingorg/32/18341_2.png) [@ProcessingOrg](https://discourse.processing.org/u/ProcessingOrg)\
**Post date:** [October 10, 2022, 6:21pm UTC](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933/5 "2022-10-10T18:21:15Z")

</div>

21 posts were split to a new topic: [[SOLVED] Drawing circles inside a circle (generative dandelion)](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197)
