Rotating ellipse around its own Y axis

Hi! I'm trying to rotate a circle around its own Y axis, but the rotation is not symmetric. It's driving me crazy and AFAIK everything is well written.

Check it out:

color myWhite = 250;
color myBlack = 13;
int centerX = 440;
int centerY = 220;

float angle=-90;

void setup(){
  size(880,440,P3D);
  background(myBlack);
  stroke(myWhite);
  strokeWeight(1);
  noFill();
}

void draw(){
  background(myBlack);
  pushMatrix();
  translate(centerX, centerY, 0); 
  rotateY(radians(angle));
  ellipse(0,0,200,200);
  popMatrix();

  angle+=2; // speed
  if (angle>=360) {
    angle=0; // keep in degree
  }

  line(centerX, 0, centerX, 440);
  line(0, centerY, 880, centerY);
  line(centerX-100, 0, centerX-100, 880);
  line(centerX+100, 0, centerX+100, 880);
}

As you can see, the top and bottom part of the circle are not cut by the central guideline simmetrically.

What I'm doing wrong?

P.S. I've taken the rotation code from here (thanks @Chrisir).

Answers

  • You are doing it wrong.

  • ellipse(-100,-100,200,200);

    Basically draw the thing centered on the origin of the Matrix which is 0,0

    hence -100

    Also

    ellipseMode (CENTER);

    or is this the default?

  • Hmm... If I use ellipse(-100,-100,200,200); it will rotate around the line of the center. I don't want that. I want the circle to rotate around it's own axis.

    Yeah ellipseMode (CENTER) is the default mode.

  • Say again what you mean

  • edited May 2016

    I want this.

    It does this.

    As you can see, the rotation is not symmetrical.

  • Minimal difference....

    Was it as good before the change I proposed?

    I think it is a small offset on the z-axis.....?

    Try making the lines with 6 parameters each (Z)

    Otherwise I can't help you

  • edited May 2016

    ellipse(-100,-100,200,200); (image)

    Yeah it's minimal, but it really bothers me haha. Also yes, it looks like it's pushed a little on the Z axis.

    It's the same with 6-parameter lines:

    line(centerX, 0, 0, centerX, 440, 0); // Vertical axis
    line(0, centerY, 0, 880, centerY, 0); // Horizontal axis
    line(centerX-100, 0, 0, centerX-100, 880, 0); // Left line
    line(centerX+100, 0, 0, centerX+100, 880, 0); // Right line
    

    EDIT

    If I change the ellipse for a sphere, it works fine. Completely symmetrical.

  • Optical issue - not in code

  • edited June 2016

    Ok =/

    Thanks for your help anyway Chrisir, appreciate it.

    EDIT

    Made this:

    void draw(){
      background(myBlack);
    
      if (w<=200 && w>0 && desc) {
        w=w-2;
      } else {
        w=w+2;
        if(w==200){
          desc = true;
        } else {
          desc = false;
        }
      }
    
      ellipse(centerX,centerY,w,200);
    
      line(centerX, 0, 0, centerX, 440, 0); // Vertical axis
      line(0, centerY, 0, 880, centerY, 0); // Horizontal axis
    
      line(centerX-100, 0, 0, centerX-100, 880, 0); // Left line
      line(centerX+100, 0, 0, centerX+100, 880, 0); // Right line
    }
    

    I'm not sure if I like it, but at least looks fine.

  • Hi

    I think it has to do with the camera view point. Try setting in your setup function:

    camera(0,0,0,0,0,0,0,0,0);

    Check the Processing3's reference : camera()

    I hope this helps,

    Kf

  • Those settings make no sense. First 3 are camera position. 2nd three are where the camera is looking, 3rd three are the up vector. Having them all the same will cause real confusion.

    Try 0, 0, -10, 0, 0, 0, 0, 1, 0 instead (camera on z axis, looking at origin, y is up)

  • edited June 2016

    @kfrajer @koogs With those settings it wouldn't work because of the translate(centerX, centerY, 0); command.

    I've modified camera settings for this:

    camera(centerX,centerY,300,centerX,centerY,0,0.0,1.0,0.0);

    But the result is the same.

    P.S. If I delete the translate command and change the camera to camera(0, 0, 300, 0, 0, 0, 0.0, 1.0, 0.0); I get the same error.

  • Optical issue - not in code

    i am increasingly convinced it is this.

    add another couple of smaller ellipses inside and you'll see.

    might be a perspective trick, might be something along the lines of affine texture mapping problem (google image search...)

  • Yeah @Crhisir said so. I guess you're both right!

    More circles

  • (i was quoting chrisir's answer)

Sign In or Register to comment.