2 random points on the circumference of a circle

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!

    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);

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

1 Like

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

1 Like

I knew it was something simple. Thank you :slight_smile:

1 Like

Hello,

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

The reference for circle():
circle() \ Language (API) \ Processing 3+ They use extent which is the diameter.

:)