Skip to content

Commit 1d16bd6

Browse files
scigirlsscigirls
scigirls
authored and
scigirls
committed
super shapes added to lib
1 parent 8cd0b2b commit 1d16bd6

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/codeandchords/Module.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import codeandchords.input.RecordedInput;
1010
import processing.core.PApplet;
1111
import processing.core.PImage;
12+
import processing.core.PShape;
1213

1314
/**
1415
* Aug. 16, 2017
@@ -1252,6 +1253,70 @@ private void inputNumErrorCheck(int inputNum, String method)
12521253
throw iae;
12531254
}
12541255
}
1256+
1257+
public PShape getSuperShape(float a, float m1, float n1, float n2, float n3)
1258+
{
1259+
float b = a;
1260+
float m2 = m1;
1261+
1262+
float[] shape = new float[100];
1263+
1264+
int i = 0;
1265+
float r = 0;
1266+
1267+
float increment = (float) (2*Math.PI/100);
1268+
1269+
for(float theta = 0; theta < 2*Math.PI; theta += increment)
1270+
{
1271+
float part1 = (float) ((1 / a) * Math.cos(theta * m1 / 4));
1272+
part1 = Math.abs(part1);
1273+
part1 = (float) Math.pow(part1, n2);
1274+
1275+
float part2 = (float) ((1 / b) * Math.sin(theta * m2 / 4));
1276+
part2 = Math.abs(part2);
1277+
part2 = (float) Math.pow(part2, n3);
1278+
1279+
float part3 = (float) Math.pow(part1 + part2, 1 / n1);
1280+
1281+
if (part3 == 0) {
1282+
r = 0;
1283+
}
1284+
else {
1285+
r = (1 / part3);
1286+
}
1287+
1288+
shape[i] = r * 100;
1289+
1290+
i++;
1291+
}//for()
1292+
1293+
PShape pshape = this.parent.createShape();
1294+
1295+
pshape.beginShape();
1296+
1297+
float x;
1298+
float y;
1299+
1300+
i = 0;
1301+
1302+
for(float theta = 0; theta < 2*Math.PI; theta += increment)
1303+
{
1304+
x = (float) (shape[i]*Math.cos(theta));
1305+
y = (float) (shape[i]*Math.sin(theta));
1306+
1307+
pshape.vertex(x, y);
1308+
1309+
i++;
1310+
1311+
}//for()
1312+
1313+
return pshape;
1314+
1315+
1316+
1317+
}
1318+
1319+
12551320

12561321

12571322
} // Module

0 commit comments

Comments
 (0)