I ran into a problem in 2 turns. A triangle is drawing using the opengldrawing primitive GL_LINES.

Scenario: I want to rotate this triangle using the Eand keys and Rtranslate this triangle along its axis of rotation by pressing the arrow keys up down left right.

But now the triangle rotates, but does not translate it along the axis of rotation. For example, in simple words, I rotate the object at an angle of 90 degrees, when the user presses the arrow key, he does not translate this triangle at an angle of 90 degrees, he simply translates this object just up and down. I am stuck on this.
This is my code:
#include<iostream>
#include <cstdlib>
#include<GL\freeglut.h>
using namespace std;
float posX = 0.0f, posY = 0.0f, move_unit = 0.01f, angle = 0.0f;
void init(void) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 1.0, -1.0);
}
void drawFigure() {
glColor3f(1.0f, 1.0f, 0.0f);
glBegin(GL_LINES);
glVertex2f(0.1f, 0.0f);
glVertex2f(-0.1f, 0.0f);
glVertex2f(0.0f, 0.1f);
glVertex2f(-0.1f, 0.0f);
glVertex2f(0.0f, 0.1f);
glVertex2f(0.1f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(0.0f, 0.1f);
glVertex2f(0.0f, 0.0f);
glEnd();
}
void SpecialKeys(int key, int xpos, int ypos) {
if (key == GLUT_KEY_UP) {
if (posY < 0.95f) {
posY += move_unit;
}
}
else if (key == GLUT_KEY_DOWN) {
if (posY > -1.0f) {
posY -= move_unit;
}
}
else if (key == GLUT_KEY_RIGHT) {
if (posX < 0.95f) {
posX += move_unit;
}
}
else if (key == GLUT_KEY_LEFT) {
if (posX > -0.95f) {
posX = posX - move_unit;
}
}
glutPostRedisplay();
}
void KeysFun(unsigned char key, int xpos, int ypos) {
if (key == 'e' || key == 'E') {
angle++;
}
else if (key == 'r' || key == 'R') {
angle--;
}
glutPostRedisplay();
}
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glTranslatef(posX, posY, 0.0f);
glRotatef(angle, 0.0f, 0.0f, 1.0f);
drawFigure();
glPopMatrix();
glFlush();
}
int main(int argc, char**argv) {
glutInit(&argc, argv);
glutInitWindowSize(600, 600);
glutInitWindowPosition(450, 50);
glutCreateWindow("C");
init();
glutDisplayFunc(display);
glutSpecialFunc(&SpecialKeys);
glutKeyboardFunc(&KeysFun);
glutMainLoop();
return EXIT_SUCCESS;
}