Vertex position after tranformation?

ok, let’s say i have a point that is at the 4,10,6 position on the current matrix (untrasformed). This is the center of my cube.

glPush()

  • Do glRotated
  • some glTranslated
  • other few glRotated

glPop()

Now the cube is transformed, and my old matrix is restored.

if i want to draw a point, in the center of the transformed cube, with the untransformed matrix (the poped one), how can i do that? eheh I need to know where the vertex is at in the untransformed matrix. Is there any formula? Maybe i can calcul my vertex with each tranformation and use it after?

I don’t really know… so help will be gradly apreciated.

Best regards,

Hi,

Before you call glPopMatrix I think you should make a call to glGetDoubleV to get the model view matrix. You can multiply the vertex you mentioned (4,10,6,1) with this matrix to get the new centre of your cube.

GA

Tanks for this information…

But my question will seems stupid… anyway, i’ll ask it anyway…

hum… it’s kinda… arf…

How do we multiply a Matrix with a Vertex?

tanks… and don’t laft!

Why don’t you just simply calculate the center of your cube before transforming it and then draw it as a point using the same matrix you used to transform the cube?

I won’t laugh. It’s pure mathematics. You know, the matrix you get is two dimenstional. It consists of 4 rows and 4 columns. Each column is a single vertex. You multiply each column with the vertex. To multiply two vertices you use this formula(the dot product formula):

Dot Product = x1x2 + y1y2 + z1z2 +w1w2

So, if you multiply the matrix M, which consists of 4*4=16 double precision floating point numbers, with a vertex V1(X1,Y1,Z1,1) you get the vertex V2(X2,Y2,Z2,1), so that:

X2 = M[0]*X1 + M[1]*Y1 + M[2 ]*Z1 +M[3 ]
Y2 = M[4]*X1 + M[5]*Y1 + M[6 ]*Z1 +M[7 ]
Z2 = M[8]*X1 + M[9]*Y1 + M[10]*Z1 +M[11]

Even though I beleive that what Gorg had said is correct, sometimes keeping a copy of the transformation matrix could be useful in late processes.

GA

Tanks softland!

Gorg: i can’t do this. Because i am working with 2 matrix at a time.

Like: I have to draw a line, from the center of my tranformed cube, to a x,y,z coord in an untransofmed matrix. Is like having a cube in a room. I must draw a line from x1,y1,z1 within my tranformed cube, to x2,y2,z2 in my room.

So, i must manualy calculate something here. If i draw my line while my matrix is transformed, i’ll have to calculate the coord x2,y2,z2 in my room with the same technique.

If i decide to draw my line when my matrix is’nt tranformed, i must calculate the x1,y1,z1 for my transformed cube.

I means, in either way, i have a point to calculate manualy.