Testing Points Around a Circle
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
// Global code will be evaluated once.
const turtle = new Turtle();
const PointRadius = 54; //min=1 max=100 step=1
const numberOfPoints = 70; //min=4 max=150 step=1
const circleRadius = 33; //min=10 max=100 step=1
var x;
var y;
var degree = 0;
var yOffset = PointRadius * 1
// Draw n points around a circle
for ( i = 0; i < numberOfPoints; i++) {
x = circleRadius * Math.cos(degrees_to_radians(degree));
y = - yOffset - circleRadius * Math.sin(degrees_to_radians(degree));
turtle.penup();
turtle.goto(x, y);
turtle.pendown();
turtle.circle(PointRadius)
degree = degree + 360 / numberOfPoints;
}
function degrees_to_radians(degrees) {
return degrees * (Math.PI / 180);
}