# Shapes3D: Toroid class is missing (new version of library)

**URL:** <https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862>\
**Category:** Libraries\
**Created:** [September 30, 2023, 5:40pm UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862 "2023-09-30T17:40:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 30, 2023, 5:40pm UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862/1 "2023-09-30T17:40:03Z")

</div>

Hello all,

I just try using an old Sketch,

but it says:

_shapes3d: Toroid class is missing_

Can anybody help me?

Chrisir

P.S.  
also failing

```auto
  boxBoard[iBox].setSize(80, 5, 80);
  boxBoard[iBox].draw();

```

(it’s an array: `Box[] boxBoard = new Box[27];`)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [September 30, 2023, 10:07pm UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862/2 "2023-09-30T22:07:43Z")

</div>

For Processing 4.3 and Shapes 3D version:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/b/9bad526066e5e788fe288e1a0b4372df6fd72f7e.png)

Following the link in the _Contribution Manager_ will lead to:

> **[Quarks Place](http://www.lagers.org.uk/s3d4p/download.html)**
>
> Shapes 3D and Processing

Version 3.0 states:

> It will not run sketches created with earlier versions.

Older versions are available and a quick look indicated that at least one of them had “toroid” in there.

`:)`

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 5, 2023, 4:32pm UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862/3 "2023-10-05T16:32:10Z")

</div>

> [@Chrisir](#):
>
> shapes3d: Toroid class is missing

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

1. `Tube` a circular or elliptical shape dragged along a path
2. `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. 🥳

```auto
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;
}

```

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 5, 2023, 4:44pm UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862/4 "2023-10-05T16:44:30Z")

</div>

Please note that the website was also completely updated for Shapes3D V3. There are a lot of guides [here](http://www.lagers.org.uk/s3d4p/libguides/lg01-introduction.html) 😀

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 6, 2023, 2:11am UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862/5 "2023-10-06T02:11:11Z")

</div>

I found this example in the archives; it is an animation of creating a toroid shape by dragging a circle in an elliptical path:

```auto
// 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;
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 6, 2023, 12:57pm UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862/6 "2023-10-06T12:57:19Z")

</div>

Toroid works fine, thanks!

* * *

**Define it :**

```auto
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:

```auto

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();
}

```

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 7, 2023, 5:11pm UTC](https://discourse.processing.org/t/shapes3d-toroid-class-is-missing-new-version-of-library/42862/7 "2023-10-07T17:11:20Z")

</div>

You can create digital art with this code:

```auto
//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();
}

```

 ![Screen Shot 2023-10-07 at 12.07.46 PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/9/e92648c8c9ad3aa9d1da7e794ba0acbf5cbd77a1.png)
