Rotation and Translation

Hi people, please help me understand how to make the following:

I have an ellipse, centered at the origin, defined by the parametric equation
(x (t ), y (t )) = (a cos(t), b(sin(t)), t being from {0, 2pi}

what is the parametric representation of the same figure translated by +2 along the x-axis, +3 along the y-axis
and then rotated by 45 degrees

I get,

x’ = cos(pi/4) -sin(pi/4) |x| + |2|
y’ sin(pi/4) cos(pi/4) |y| |3|

to be read as the matrix multiplication of cos, -sin by original coordinates
plus the vector 2, 3 yielding the new coordinates…but this is not in homogeneous
coordinates…how to make it homogeneous…

and any additional info will be appreciated for the Math-phobic among us…

thanks,

bernie

So, here’s some code, but what this does, every time I resize the window, It re calculates the origin, and moves right off the screen…
so what gives…thanks
bernie (yes, I know its c code, but you people are so nice :slight_smile: )

#include
#include
#include <glut.h>
#include <math.h>

const float DEG2RAD = 3.1416/180;

void init(void){
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,1.0,0,1.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();

}

void disp(void){
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(0.0,0.0,0.0);
float xradius = 0.25;
float yradius = 0.125;

glBegin(GL_LINE_LOOP);

for (int i = 0; i<360; i++){
float degInRad = i*DEG2RAD;
glVertex2f(cos(degInRad)*xradius, sin(degInRad)*yradius);
}
glEnd();

glRotatef (45,0,0,1);
glTranslatef(.75,.25,0);
glBegin(GL_LINE_LOOP);

for (int j = 0; j<360; j++){
float degInRad = j*DEG2RAD;
glVertex2f(cos(degInRad)xradius, sin(degInRad)yradius);
}
glEnd();
glFlush();
}
void main(int argc, char
argv){
glutInit (&argc, argv); // Initialize GLUT.
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // Set display mode.
glutInitWindowPosition (50, 100); // Set top-left display-window position.
glutInitWindowSize (400, 300); // Set display-window width and height.
glutCreateWindow (“ellipse”); // Create display window.
init ( ); // Execute initialization procedure.
glutDisplayFunc (disp); // Send graphics to display window.

glutMainLoop ( ); // Display everything and wait.
}