In another discussion you asked about restoring the Toroid class to Shapes3D V3. I will answer the question here because it fits the discussion title better.
The simple answer is NO but don’t despair read on
Shapes3D V3 is a complete reworking of the library and introduced new classes and features which made some older classes redundant - Toroid was one of them. One of the new features was the ability to generate 3D shapes by dragging a 2D shape (cross-section) along a 2D/3D path. This is facilitated by two new / updated classes
Tube a circular or elliptical shape dragged along a path
Extrusion a polygon (either concave or convex) dragged along a path
A toroid can be created by dragging a circle round a circular path. The following code demonstrates how to do this.
import shapes3d.*;
import shapes3d.contour.*;
import shapes3d.org.apache.commons.math.*;
import shapes3d.org.apache.commons.math.geometry.*;
import shapes3d.path.*;
import shapes3d.utils.*;
Tube torroid;
float ax, ay, az;
void setup() {
size(400, 400, P3D);
// Create the torroid
torroid = makeTorroid(100, 100, 48, 30, 30, 24);
// Set render attributes for torroid
torroid.use(S3D.BODY)
.fill(color(160, 160, 255))
.stroke(color(0, 0, 160))
.strokeWeight(0.75)
.drawMode(S3D.WIRE | S3D.SOLID);
}
void draw() {
background(200);
push();
translate(width/2, height/2);
// The next few lines rotate the graphics
// context so we view the shape from different
// angles making it appear to be tumbling.
ax += 0.0043;
ay += 0.0093;
az += 0.0079;
rotateX(ax);
rotateY(ay);
rotateZ(az);
torroid.draw(getGraphics());
pop();
}
/*
Many shapes can be created by extruding a 2D shape (cross-sectiorn) along a path.
To create a torroid the cross-sectiorn will be a simple circle (an ellipse with
both axis the same length) and a circular (elliptical) path.
In this function we create a circular path with x radius 'ringX' and y radius 'ringY'
and the path will be made from 'nbrSlices' straight segments.
Next we create the cross-section to ectrude - again a simple circle (an ellipse with
both axis the same length)
Finally we use them to create an instance of Tube that looks like a torroid.
*/
Tube makeTorroid(float ringX, float ringY, int nbrSlices,
float crossX, float crossY, int nbrSegs) {
// Create tube path (circular / elliptical
Path path = new Ring(ringX, ringY, nbrSlices);
// Create torroid cross-section
Oval oval = new Oval(crossX, crossY, nbrSegs);
// Extrude oval round path to create torroid
Tube torroid = new Tube(path, oval);
return torroid;
}
I found this example in the archives; it is an animation of creating a toroid shape by dragging a circle in an elliptical path:
// https://forum.processing.org/one/topic/move-elements-along-the-ellipse-path.html
//Value is position in elliptical orbit: 0 to 2*PI
float val = 0;
//Speed of object in the orbit
float speed = 0.05;
void setup(){
size(500, 500);
surface.setTitle("Animated Toroid");
}
void draw(){
//Calculate x and y as values between -1 and 1
float x = sin(val);
float y = cos(val);
//Multiply x and y by the ellipses width and height
x *= 100; // ellipse width
y *= 50; // ellipse height
//Move the center point of the elliptical orbit where you want it
x += width/2;
y += height/2;
fill(255,0,0);
circle(x,y,50);
//Update the value
val += speed;
}
void defineToroid() {
// Create the torroid
toroid = makeToroid(100, 100, 48,
30, 30,
24);
color colO=color(0, 255, 0);
// Set render attributes for torroid
toroid.use(S3D.BODY)
.fill(colO)
.stroke(colO)
.scale(.21)
.drawMode(S3D.SOLID);
}
/*
Many shapes can be created by extruding a 2D shape (cross-sectiorn) along a path.
To create a toroid the cross-sectiorn will be a simple circle (an ellipse with
both axis the same length) and a circular (elliptical) path.
In this function we create a circular path with x radius 'ringX' and y radius 'ringY'
and the path will be made from 'nbrSlices' straight segments.
Next we create the cross-section to extrude - again a simple circle (an ellipse with
both axis the same length)
Finally we use them to create an instance of Tube that looks like a toroid.
*/
Tube makeToroid(float ringX, float ringY,
int nbrSlices,
float crossX, float crossY,
int nbrSegs) {
// Create tube path (circular / elliptical
Path path = new Ring(ringX, ringY, nbrSlices);
// Create torroid cross-section
Oval oval = new Oval(crossX, crossY, nbrSegs);
// Extrude oval round path to create torroid
Tube toroid = new Tube(path, oval);
return toroid;
}
Use it:
void paintO () {
// all defs see void setup()
push();
// The next few lines rotate the graphics
// context so we view the shape from a different
// angle
rotateX(ax);
// rotateY(ay);
// rotateZ(az);
toroid.draw(getGraphics());
pop();
}
//Value is position in elliptical orbit: 0 to 2*PI
float val = 0;
//Speed of object in the orbit
float speed = 0.05;
float ax, ay, az;
void setup() {
size(800, 800, P3D);
surface.setTitle("Animated Toroid");
}
void draw() {
push();
//Calculate x and y as values between -1 and 1
float x = sin(val);
float y = cos(val);
//Multiply x and y by the ellipses width and height
x *= 100; // ellipse width
y *= 50; // ellipse height
//Move the center point of the elliptical orbit where you want it
x += width/2;
y += height/2;
fill(255, 0, 0);
ax += 0.0043;
ay += 0.0093;
az += 0.0079;
rotateX(ax);
rotateY(ay);
rotateZ(az);
circle(x, y, 50);
//Update the value
val += speed;
pop();
}