Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Replace sphere with ellipses in 3D mode

$
0
0

Dear all interested readers,

The next sketch makes this:

A 3D grid with spheres, to be rotated with the use of peasy.

Schermafbeelding 2018-03-09 om 19.41.00

I would, however, replace the spheres by ellipses, to make a better PDF output. But, of course, when I replace a sphere with an ellipse, the ellipse would rotate and loses the shape of a perfect circle.

What would it take to maintain the orientation of the ellipse while rotating the cube?

Thanks in advance for helping me out :-)

code:


import processing.pdf.*;

import peasy.*; import peasy.org.apache.commons.math.*; import peasy.org.apache.commons.math.geometry.*;

PeasyCam cam;

int afstand = 70;

boolean record;

void setup() { size(600, 600, P3D);

cam = new PeasyCam(this, 10000);

noStroke(); fill(0);

ortho(-width, width, -height, height); } void draw() {

background(#ffffff);

if (record) { beginRaw(PDF, "cube.pdf"); }

for (int i=0; i<8; i++) { for (int j=0; j<8; j++) { for (int k=0; k<8; k++) {

    pushMatrix();

    translate((i-3)*afstand, (j-3)*afstand, (k-3)*afstand);


    sphere(10);
    popMatrix();
  }
}

}

if (record) { endRaw();

record = false;

} }

void keyPressed() { record = true; }


Viewing all articles
Browse latest Browse all 2896

Trending Articles