Q:

rotation on the axis of a moving body

I'm just learning how to use push and pop matrices. I want the car(object) to rotate on its axis and not(revolve) with the 0,0 of the translated coordinate. {Beginner programming hobbyist}
Tried re-translating the axes when I use rotate().
PImage c = new PImage();

Car forza = new Car();
Trees tr = new Trees();

float wrap = 100;

void setup(){
  size(800,800);
}

void draw(){
  background(0);
  forza.update();
  forza.display();
  tr.road();
}

class Car {

  float posX;
  float posY;
  float speed;
  float accel;
  float angle;

  Car(){
    posX = 0;
    posY = 0;
    speed = .9;
    angle = sin(0);
    accel = 0;
  }

  void update(){
    pushMatrix();
    translate(posX,posY);
    if (keyPressed) {
      if (key == 'd') {
        angle += 1;
      }else if (key == 'a'){
        angle -= 1;
        rotate(radians(angle));
      } else if (key == 'w'){
        posX += speed;
      } else if (key == 's'){
        posX -= speed;
      }
    }  
    popMatrix();
  }

  void display(){
    pushMatrix();
    translate(width/2,height/2);
    rotate(radians(angle));
    c = loadImage("car.jpg");
    fill(255);
    stroke(255);
    imageMode(CENTER);
    image(c,posX,posY,wrap,wrap);
    line(0,0,posX,posY);
    print(posX);
    println(posY);
    popMatrix();
  }

}

class Trees {
  float x;
  float y;

  Trees(){
    //x = random(0,);
  }

  void trash(){

  }
  void road(){
    fill(250,50);
    rectMode(CENTER);
    rect(width/2,height/2, width/2, height);
  }

  void show(){

  }
}

I just wanna know the algorithm for it, and if any other way of doing the algorithm in terms of efficiency and aesthetics. ^^

A:

If the object should rotate around its origin, then the rotation has to be done before the translation. Since operations like rotate() and translate() set a matrix and multiply the current matrix by the new matrix, this means that rotate() has to be done last before drawing the object. Even drawing an object at the a certain position (e.g. posX, posY) behaves like a translation.  
You have to draw the car at position (0, 0). Then you've to rotate it. Finally translate it to its final position:
void display(){
    pushMatrix();
    translate(width/2,height/2);

    pushMatrix();
    translate(posX,posY);
    rotate(radians(angle));

    fill(255);
    stroke(255);
    imageMode(CENTER);
    image(c,0,0,wrap,wrap);
    popMatrix();

    line(0,0,posX,posY);
    popMatrix();
}

The matrix manipulation operations, change the matrix. The matrix is applied to the coordinates in of the drawing operations. The matrix operations in update are useless, because at the begin is a pushMatrix() at the end a popMatrix(), but nothing is draw at all.
It is a wast of performance, to load the image in every frame, do it once in the constructor of Car.
See the example:

Car forza;
Trees tr;
float wrap = 100;

void setup(){
    size(800,800);
    forza = new Car();
    tr = new Trees();
}

void draw(){
    background(0);
    forza.update();
    forza.display();
    tr.road();
}

class Car {

    float posX;
    float posY;
    float speed;
    float accel;
    float angle;
    PImage c;

    Car(){
        posX = 0;
        posY = 0;
        speed = .9;
        angle = sin(0);
        accel = 0;
        c = loadImage("car.jpg");
    }

    void update(){
        if (keyPressed) {
          if (key == 'd') {
            angle += 1;
          }else if (key == 'a'){
            angle -= 1;
          } else if (key == 'w'){
            posX += speed;
          } else if (key == 's'){
            posX -= speed;
          }
        }  
    }

    void display(){
        pushMatrix();
        translate(width/2,height/2);

        pushMatrix();
        translate(posX,posY);
        rotate(radians(angle));

        fill(255);
        stroke(255);
        imageMode(CENTER);
        image(c,0,0,wrap,wrap);
        popMatrix();

        line(0,0,posX,posY);
        popMatrix();
    }
}

class Trees {
    float x;
    float y;

    Trees(){
      //x = random(0,);
    }

    void trash(){

    }
    void road(){
      fill(250,50);
      rectMode(CENTER);
      rect(width/2,height/2, width/2, height);
    }

    void show(){

    }
}

