Content All Articles Python News Numerically Python Python & XML Python Topics CommunityDatabaseDistributedEducationGetting StartedGraphicsInternetOSProgrammingScientificToolsTutorialsUser Interfaces ONLamp Subjects Linux Apache MySQL Perl PHP Python BSD

Transformation Matrices

07/05/2000

This month we'll use NumPy and DISLIN to create, display, and manipulate a basic geometric image. At the heart of image manipulation are special matrices that can be used to create effects. You can use these effects separately or combine them for more complex operations. While the focus is on two-dimensional operations, the concepts extend to three (and more) dimensions. They are fundamental to many applications including computer games and computer-aided design (CAD) programs. They are the heart of linear algebra itself.

So what's a vector?

Linear algebra is the math of shaped collections of numbers. The mathematics we are most familiar with deals with numbers called scalars. We use scalars in our lives to represent things like the amount in our bank account (\$10.08), the speed we drive (65 miles per hour), or the time it takes for popcorn to pop in the microwave oven (3 minutes 40 seconds). Each of these values is a magnitude of some quantity that interests us. Often we use combinations of values to represent more complex information. For example, there is a difference between the speed of an object (say your car) and its velocity. One is simple magnitude (speed: how fast you are going); the other implies both speed and direction (velocity). Your speed cannot be negative, but your velocity could be. Think about your car moving in reverse. You are moving so you have speed, but the direction is "backwards," giving you a negative velocity. Speed is a scalar value, but velocity is expressed as a vector, a combination of two numbers that imply both direction and magnitude. Assuming your car is driven on a flat road, only two numbers are needed to represent the direction of movement.

Considering the world as a flat plane, we can lay on it two reference directions. The arrows labeled x and y provide a reference for our vector .

The vector is defined as being four units in the x direction and 3 units in the y direction (units, in this case, being miles traveled.) So how do we get from the motion of a car to a vector of ? Well we would say that the velocity of the car is miles per hour. Which means that the car moved four miles in the x direction and three in the y in the last hour. The actual motion of the car is the length of the vector, computed via:

This is just the Pythagorean theorem, which seems to pop up everywhere! Continuing with the example, the car moved a total of five miles in the course of a single hour and as such went five miles per hour.

If we want to describe motion of objects that can move in more dimensions (say an airplane - which can move "up" and "down" as well), we have to use vectors with more elements (three for the airplane).

Vectors are used to represent many things -- the velocity of an automobile is but one real example. In general, the concept of a vector is abstract. You don't need to know what a vector represents in order to manipulate it, although knowing sometimes helps you understand what you are doing. The mathematics for manipulating vectors can be considered separately from the implementation of a particular problem.

Instead of graphing velocity, we will use vectors to draw a basic image. We will then focus on the manipulation of this image via special matrices and matrix mathematics.

 Pages: 1, 2, 3, 4, 5