# 2 random points on the circumference of a circle

**URL:** https://discourse.processing.org/t/2-random-points-on-the-circumference-of-a-circle/31129
**Category:** Coding Questions
**Created:** [July 9, 2021, 7:03am UTC](https://discourse.processing.org/t/2-random-points-on-the-circumference-of-a-circle/31129 "2021-07-09T07:03:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gentle\_ben](https://avatars.discourse-cdn.com/v4/letter/g/e274bd/32.png) [@gentle\_ben](https://discourse.processing.org/u/gentle_ben)
#### Post date: [July 9, 2021, 7:03am UTC](https://discourse.processing.org/t/2-random-points-on-the-circumference-of-a-circle/31129/1 "2021-07-09T07:03:03Z")

</div>

Hi, hope you can help me. I’m sure this is simple.

I’ve found many references to getting random point on the edge of circle using (cos(angle)\*radius, sin(angle)\*radius) but what i have come up with generates points that don’t seem to have an obvious relationship to my circle. I’m trying to generate 2 such points and connect them with a line. I’m clearly missing something fundamental. Help!

```auto
    float x = 200;
    float y = 200;
    float rad = 100;
    circle(x, y, rad);
    float a = random(TWO_PI);
    float x1 = cos(a)*rad+x;
    float y1 = sin(a)*rad+y;
    a = random(TWO_PI);
    float x2 = cos(a)*rad+x;
    float y2 = sin(a)*rad+y;
    line(x1, y1, x2, y2);

```

---

<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: [July 9, 2021, 7:43am UTC](https://discourse.processing.org/t/2-random-points-on-the-circumference-of-a-circle/31129/2 "2021-07-09T07:43:25Z")

</div>

The circle is drawn with 3rd parameter being **diameter** , not the radius (as you seem to assume)

---

<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: [July 9, 2021, 7:43am UTC](https://discourse.processing.org/t/2-random-points-on-the-circumference-of-a-circle/31129/3 "2021-07-09T07:43:51Z")

</div>

> [@gentle\_ben](#):
>
> `circle(x, y, rad);`

Try rad/2 here please [or double the radius when calculating the two points]

---

<div class="post-metadata">

### Author: ![gentle\_ben](https://avatars.discourse-cdn.com/v4/letter/g/e274bd/32.png) [@gentle\_ben](https://discourse.processing.org/u/gentle_ben)
#### Post date: [July 9, 2021, 11:12am UTC](https://discourse.processing.org/t/2-random-points-on-the-circumference-of-a-circle/31129/4 "2021-07-09T11:12:21Z")

</div>

I knew it was something simple. Thank you 🙂

---

<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: [July 9, 2021, 1:09pm UTC](https://discourse.processing.org/t/2-random-points-on-the-circumference-of-a-circle/31129/5 "2021-07-09T13:09:21Z")

</div>

Hello,

There are resources (tutorials, references, examples. etc.) here:  
[https://processing.org/](https://processing.org/)

The reference for circle():  
_[circle() \ Language (API) \ Processing 3+](https://processing.org/reference/circle_.html)_ They use _extent_ which is the _diameter_.

`:)`
