[WPI] [cs4731] [Classes]

cs4731, D96/97 Class 3

Transforms

Using the notation from Class 2, the transformations between world, normalized viewport, and digital image coordinates are described by these linear equations.

Data types

We introduced two data structures that will be useful and methods for declaring/initializing them.

typedef struct f_point
	{
	float x; /* point coordinates */
	float y;
	float z;
	float w;
	struct f_point *next; /* for linked list */
	} f_point; /* newly defined type */

typedef struct digital_image
	{
	unsigned int cols; /* digital image size */
	unsigned int rows;
	unsigned int colors; /* 1 for gray scale; 3 for color */
	unsigned char *image; /* the image array */
	struct digital_image *next; /* for linked list */
	} digital_image; /* newly defined type */

Note that the f_point is designed to be used in a linked list. It can be used for an isolated point, a line, or a polyline (a connect-the-dots type of closed figure) of 2, 3, or 4 dimensions.

The digital_image is also designed to be used in a linked list -- for animations -- and the pixel data are stored in a one-dimensional array, which is widely used in computer graphics (sometimes it is called the pixel buffer). Thus, the conversion from X, Y coordinates to the location in the pixel buffer pointed to by my_image is:

 *(my_image->image + Y*cols + X);

Vectors

We reviewed some aspects of vectors. They are covered in the vector notes.

 


 
WPI Home Page
[cs4731] [Classes]

Contents ©1997, Norman Wittels
Updated 25Mar97