Why does this effect occur with ortho?

I have a letter A, which goes in a spiral when you look at it from the top. All those positions that form the A are stored in a PShape as points. When I draw them in ortho mode I get really strange results:

Screen Shot 2017-06-12 at 14.57.37 Screen Shot 2017-06-12 at 14.57.51 Screen Shot 2017-06-12 at 14.58.01 Screen Shot 2017-06-12 at 14.58.13 Screen Shot 2017-06-12 at 14.58.23

why does that happen?

Answers

  • which goes in a spiral when you look at it from the top. ... why does that happen?

    Please share your code or a small sample sketch demonstrating the problem in order to get better feedback. There are so many things that "goes in a spiral" could mean.

    1. You said you were in ortho mode, but the letter is free-rotated -- are you also using peasycam?
    2. When you say "why does that happen" what do you mean by "that" specifically?
    3. You have shown several different images, what do you do differently in order to get each image?
  • edited June 2017

    Here is the code and the 2 images used. Change the rotateZ to see the effect. In the OP i doubled them every time.

    ArrayList<PVector> vecs = new ArrayList<PVector>();
    PShape s;
    
    void setup() {
      size(800, 800, P3D);
      foo();
    
      s = createShape();
      s.beginShape(POINTS);
      s.stroke(255);
      s.strokeWeight(0.5);
      for (PVector v : vecs) {
        s.vertex(v.x, v.y, v.z);  
      }
      s.endShape();
    
    
    
    }
    
    void draw() {
      ortho();
      background(0);
    
    
    
    
      translate(width/2, width/2, 500);
      //translate(mouseX, mouseY, 0);
    
      //translate(-(160/2), -(150/2), 0);
      scale(0.5);
      //rotateY(radians(frameCount));
      //rotateX(radians(frameCount/2));
      //rotateZ(radians((float)frameCount/30));
      rotateZ(0.01);
      //for (PVector v : vecs) {
      //  point(v.x, v.y, v.z);  
      //}
      shape(s);
    
      surface.setTitle(""+frameRate);
    
    }
    
    
    void foo() {
      PImage a = loadImage("3_B.png");
      PImage b = loadImage("3_A.png");
    
      a.loadPixels();
      b.loadPixels();
    
      int idx = 0;
      for (int z = 0; z < a.height; z++) {
        for (int x = 0; x < a.width; x++) {
    
          int c1 = a.pixels[idx];
          idx += 1;
          if (c1 == -1) continue; // white
    
          for (int y = 0; y < a.height; y++) {
            int c2 = b.pixels[x + y*a.width];
            if (c2 == -1) continue; // white
            vecs.add(new PVector(x, y, z));  
          }
    
    
    
        }
      }
    
    
    }
    

    3_A 3_B

  • which image is which?

    PImage a = loadImage("3_B.png");
    PImage b = loadImage("3_A.png");
    

    tells us nothing!

  • (the spiral is the first one.)

    if you add peasycam (and comment out the ortho) you can kind of see what it's doing - it's a point cloud and the interference between the layers is causing patterns. it's worse with ortho because all the distance layers get collapsed to one layer.

    import peasy.*;
    
    ArrayList<PVector> vecs = new ArrayList<PVector>();
    PShape s;
    PeasyCam cam;
    
    void setup() {
      size(800, 800, P3D);
      foo();
      cam = new PeasyCam(this, 100);
    
      s = createShape();
      s.beginShape(POINTS);
      s.stroke(255);
      s.strokeWeight(0.5);
      for (PVector v : vecs) {
        s.vertex(v.x, v.y, v.z);
      }
      s.endShape();
    }
    
    void draw() {
      //ortho();
      background(0);
      shape(s);
    }
    
    void foo() {
      PImage a = loadImage("spiral.png");
      PImage b = loadImage("a.png");
    
      a.loadPixels();
      b.loadPixels();
    
      int idx = 0;
      for (int z = 0; z < a.height; z++) {
        for (int x = 0; x < a.width; x++) {
    
          int c1 = a.pixels[idx];
          idx += 1;
          if (c1 == -1) continue; // white
    
          for (int y = 0; y < a.height; y++) {
            int c2 = b.pixels[x + y*a.width];
            if (c2 == -1) continue; // white
            vecs.add(new PVector(x, y, z));
          }
        }
      }
    }
    
  • It seems to be more then interference, cause with a rotation of 0 I see nothing.

  • That's because with no rotation all the pixels line up as they should, next to each other, making it appear solid.

    (Guessing a bit here)

  • That still makes no sense. Cause with 0 rotation I see nothing for example.

Sign In or Register to comment.