MaxBeauchemin
4/20/2020 - 1:28 PM

Polar to Cartesian - Draw Circle

var radius = 0.5;
var currAngle = 0;
var angleStep = 360 / arr.length;

  //In loop
  var currRadians = (currAngle * Math.PI) / 180;
  var x = radius * Math.cos(currRadians);
  var y = radius * Math.sin(currRadians);

  currAngle += angleStep;
//https://editor.p5js.org/

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  
  var radius = 100;
  var currAngle = 0;
  var count = 23;
  var angleStep = 360 / count;

  for (var i = 0; i < count; i++){
    var currRadians = (currAngle * Math.PI) / 180;
    var x = radius * Math.cos(currRadians);
    var y = radius * Math.sin(currRadians);

    currAngle += angleStep;
    
    stroke('purple'); // Change the color
    strokeWeight(10); // Make the points 10 pixels in size
    point(x + 200, y + 200);
  }    
}