# Creating 3D animation with math expressions

**URL:** <https://discourse.processing.org/t/creating-3d-animation-with-math-expressions/40152>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [December 13, 2022, 1:51pm UTC](https://discourse.processing.org/t/creating-3d-animation-with-math-expressions/40152 "2022-12-13T13:51:31Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [December 13, 2022, 8:14pm UTC](https://discourse.processing.org/t/creating-3d-animation-with-math-expressions/40152/3 "2022-12-13T20:14:15Z")

</div>

Hello @aalgoro,

This topic may be of interest:

> [@How to go from plane to 3D](https://discourse.processing.org/t/how-to-go-from-plane-to-3d/38263):
>
> float t=1; void setup() { size(800, 800); } void draw() { background(0); noStroke(); fill(255); translate(width/2, height/2); for (int i = 0; i \< 100; i++) { float x = width/4 \* sin(t\*i\*PI\*2); float y = height/4 \* sin(t\*i\*PI\*3); rect(x,y,2,2); } t += 0.00001; } Hello, I have this system of equations that cause the points to move like on a Lissajous curve. I’m trying to add a third dimension to it and be able to change the point of view of the camera to visu…

Code from above simplified:

```auto
void setup() 
  {
  size(800, 800, P3D);
  }

void draw() 
  {
  background(255);
  strokeWeight(5);
  
  translate(width/2, height/2);

  for (int i = 0; i < 300; i++) 
    {
    float x = width/4*sin(i*PI*2/100);
    float y = height/4*sin(i*PI*3/100);
    float z = 200*sin(i*PI*4/100);
    point(x, y, z);
    }
  }

```

Additional references:  
[https://processing.org/tutorials/trig](https://processing.org/tutorials/trig)

The above site is poorly formatted and this is cleaner:

```auto
x = cosine(theta)*radius 
y = sine(theta)*radius

```

```auto
float x = cos(radians(angle))*radius;
float y = sin(radians(angle))*radius;

```

Have fun!

`:)`

---

_[View the full topic](https://discourse.processing.org/t/creating-3d-animation-with-math-expressions/40152)._
