xxxxxxxxxx
// Orthoplex Experiment - Varying Vertices
// Robert S. Robbins
// http://www.williamsportwebdeveloper.com/
// https://en.wikipedia.org/wiki/8-orthoplex
// Create an array to hold thirty two points
PVector[] pv= new PVector[32];
void setup() {
size(700, 700);
rectMode(CENTER);
smooth();
}
void draw() {
background(255);
stroke(0,0,0);
strokeWeight(1.4);
fill(255,255);
// Invert the y axis
scale(1, -1);
translate(0, -height);
// this centers what is drawn
translate(width / 2, height / 2);
// Set the radius
int r = 300;
// Change the number of points
NumberOfPoints = map(sin(frameCount * .01), -1, 1, 6, 32);
// Create a set number of points around the radius of the circle to divide the circle into equal parts
for(float i = 1; i <= NumberOfPoints; i++)
{
angle = i * (TWO_PI/NumberOfPoints);
pv[i] = new PVector(r * cos(angle), r * sin(angle));
}
// Draw lines between each point
for(float i = 1; i <= NumberOfPoints; i++)
{
for(float j = 1; j <= NumberOfPoints; j++)
{
line(pv[i].x, pv[i].y, pv[j].x, pv[j].y);
}
}
// Draw the points used
stroke(0,0,0);
strokeWeight(2);
fill(255,0,0);
for(float i = 1; i <= NumberOfPoints; i++)
{
ellipse(pv[i].x, pv[i].y, 15, 15);
}
}