PDA

View Full Version : How to Perform a Composite Concatenation [Transformation] Through Code



umartariq
11-07-2017, 01:09 AM
using C++ , OpenGL , and Visual Studio 2013 IDE



void drawSquare(){
glBegin(GL_QUADS); //Primitive
glVertex2i(200, 100);//vertices for points(coordinates)
glVertex2i(250, 100);
glVertex2i(250, 150);
glVertex2i(200, 150);
glEnd();

}




void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
drawSquare();
glTranslatef(1.5, 1.5, 0);
drawSquare();
glScalef(0.3, 0.3, 0);
drawSquare();
glRotatef(45, 0, 0, 1);
drawSquare();
glFlush(); //Set all output to display
}

does this code perform composite concatenation ?



Question

Build a transformation that
a) Rotate through 45 deg [M1]
b) Scale in X By 1.5 and in Y By -2 [M2]
c) Translate Through (3,5) [M3]

Find the image under this transofrmation of the point (1,2)


so we will work backwards and first apply part c then part b then part a

i.e M3 * M2 * M1

Step-1

2541


Step-2

2542


i understood the process of Composite Concatenation

what i dont understand is how to perform a composite concatenation through program code ?

consider the code i posted at the very beginning

it calls

drawSquare
glRotate
drawSquare
glTranslate
drawSquare


is this composite concatenation ?

how do i use the final generated Matrix (Qx,Qy,1) and use it to perform composite concatenation

Dark Photon
11-07-2017, 06:49 AM
does this code perform composite concatenation ?
...
i understood the process of Composite Concatenation
what i dont understand is how to perform a composite concatenation through program code ?

Websearch glTranslatef (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml) and glRotatef (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glRotate.xml) and read the manual pages. They'll tell you the answer.

For other related reading, websearch 'Composite Concatenation opengl'.