Vector graphics refers to representing images by mathematical descriptions of geometric objects, rather than by a collection of pixels on the screen (raster graphics).
Let’s represent the ship by a triangle, starting with its vertices at (0, 0), (2, 0), (1, 3).
With a simple modification of the vertex matrix, though, we can represent translation by matrix multiplication using shear transformations (adds a multiple of one coordinate to each of the other coordinates). We just add a dummy coordinate that always holds value 1, and add multiples of that to the x and y coordinates.
Homogeneous Coordinates
Translation by (r, s) is now the product
Flying Forward
Suppose we want to fly our ship two units in the direction it is currently facing (up). We need to translate by (0, 2):
The new vertices, (0, 2), (2, 2), (1, 5), give us the new ship image:
Turning in Place
We’ll crash into an asteroid if we can’t change direction. Let’s find the images of the columns of I2 under counterclockwise rotation at an angle of ᵠ.
The first two columns of I3 will do just the same thing, with a zero in the last place. Our extra coordinate will stay the same. Hence to obtain counterclockwise rotation by ' degrees, we multiply by the matrix
For example, for a 90_ turn to the left, we would compute:
That’s not the way ships turn, though! And if we rotate our ship after it drives up 2 units, it’s even worse:
Center of Ship vs. Center of Screen
One solution is to translate, rotate, and translate back: make the center of the triangle the origin, do the rotation as previously, and then move the center back where it belongs. If we move everything by the amount the center requires, everything will stay in its proper positions.
We multiply on the left by each operation’s matrix in order. Hence the new vertices are given by A−1BAM where M is the matrix of homogeneous coordinates, A gives translation by (−1,−1.5), B rotation by 90_, and A−1 translation by (1, 1.5).
The multiplication claims our vertices after rotation should be at (2.5, 0.5), (2.5, 2.5), and (−0.5, 1.5). Let’s graph it.
http://www.math.dartmouth.edu/
nice post dina it's very interestingow to know this i didnt have any idea befor about it
ReplyDeletevery smart example dina more specificly about "turning in place" without changing the direction we can get image of the columns
ReplyDeletemniha mniha dina
ReplyDeletenice post, interesting informations and clear pictures but isn't so long ?
ReplyDeletevery interesting post dina,it seems that matrices is involved in every thing we do in our lives. thank you for this info's.
ReplyDeleteDina, a great post indeed!!!!!! after all your frustration on posting, you finally did it and you did a great job!
ReplyDeleteI like it when they said that the ship must change directions otherwise it might hit an asteroid! :)
Thanks Dina!
I never thought that matrices can move a ship!!
ReplyDeletenice work Dina :)