Fabricio
Fabricio

Reputation: 7925

How to apply matrices - an understanding request

Suppose I have a cube as

P1(0, 0, 0) P5(0, 0, 1)
P2(1, 0, 0) P6(1, 0, 1)
P3(0, 1, 0) P7(0, 1, 1)
P4(1, 1, 0) P8(1, 1, 1)

Now I need to apply transformation/rotation/scale matrices. Say,

transform = Pt(3, 3, 5)
rotation = 30º
scale = 2x`

Ok. But, where do I put each of these values into the matrices in order to get the final result? That confuses me alot.

edit

Lets say, for the P2, I have:

| 1 |   | a b c |
| 0 | x | d e f | = R
| 0 |   | g h i |

But what do I have in a,b,c,d,...i ?

Upvotes: 0

Views: 52

Answers (2)

John Alexiou
John Alexiou

Reputation: 29244

To do it with a single operation you need a 4x4 matrix. Look at http://www.engineering.uiowa.edu/~ie_246/Lecture/OpenGLMatrices.ppt for some details and examples.

In the end you chain the transformations like this

point[i] = T1*T2*T3*..*vertex[i]

PDF Conversion

Upvotes: 3

duffymo
duffymo

Reputation: 308743

Each of the 8 points on the corners of the cube are a 3x1 vector. Your matrix transformations are 3x3 matricies.

Rotation about what axis? That will change what that rotation matrix will look like. Here's what it is about the x-axis:

     | +cos(theta) -sin(theta)  0 | 
Rx = | +sin(theta) +cos(theta)  0 |
     | 0           0            1 |

The scale is easy: Multiply all the x-coordinates by a factor of two.

    | 2  0  0 |
S = | 0  1  0 |
    | 0  0  1 |

Apply these to each of your points.

Upvotes: 0

Related Questions