19
Computer Graphics Raster Devices Transformations Areg Sarkissian

Computer Graphics Raster Devices Transformations

  • Upload
    zarola

  • View
    34

  • Download
    0

Embed Size (px)

DESCRIPTION

Computer Graphics Raster Devices Transformations. Areg Sarkissian. Raster Devices. Most displays used for computer graphics are raster displays. The surface of raster displays has a certain number of pixels that it can show, such as 640 X 480 ~ 307,000 pixels - PowerPoint PPT Presentation

Citation preview

Page 1: Computer Graphics Raster Devices Transformations

Computer GraphicsRaster Devices

Transformations

Areg Sarkissian

Page 2: Computer Graphics Raster Devices Transformations

Raster Devices

Most displays used for computer graphics are raster displays. The surface of raster displays has a certain number of pixels that it

can show, such as 640 X 480 ~ 307,000 pixels All raster displays have a built-in coordinate system that associates

a given pixel in an image with a given physical position on the display surface.

The horizontal coordinate Sx increases from left to right, and the vertical coordinate Sy increases from top to bottom. They have an upside-down coordinate system. (0,0) (639,0)

(0,479)

Consist of three main parts: 1) Frame Buffer 2) Scan Controller 3) Digital to Analog Converter (DAC)

Page 3: Computer Graphics Raster Devices Transformations

Frame Buffer A region of memory sufficiently large to hold all of the pixel values for

display. A graphic card that is installed in a personal computer actually houses the

memory required for the frame buffer. The display memory can be thought of a two dimensional array: mem[x][y]

Page 4: Computer Graphics Raster Devices Transformations

Scan Controller & DAC

The scan controller causes the frame buffer to send each pixel through a converter to the appropriate physical spot on the display surface.

The scan controller addresses one pixel value, mem[x][y], in the frame buffer at the same time it addresses one position, (x, y), on the face of CRT.

The converter takes a pixel value such as 010010 and converts it to the corresponding quantity that produces a spot for each red, green, and blue colors on the display.

The dots are so close together that eye sees one composite dot and a single color that is the sum of the three component colors. Thus, the composite dot can be made glow in a total of 4x4x4=64 different colors.

Page 5: Computer Graphics Raster Devices Transformations
Page 6: Computer Graphics Raster Devices Transformations

Scan Controller & DAC

Some of the more expensive systems have a frame buffer that support 24 planes of memory. Each of the DACs has eight input bits, so there are 256 level of red, green, blue. (16 million colors)

MonochromA single DAC converts pixel values in the frame buffer to voltage levels,

which drive a single electron-beam gun. Note that 6 planes in frame buffer give 64 levels of gray.

Page 7: Computer Graphics Raster Devices Transformations

Indexed Color and the Lookup Table

A color lookup table (LUT), which offers a programmable association between a pixel value and the final displayed color

The color depth is again six, but the 6 bits stored in each pixel go through an intermediate step before they drive the CRT.

These bits are used as an index into a table of 64 values (LUT[0]…LUT[63])

Each LUT[i] contains a 15-bit value, which every five bits drives corresponding DAC. (Red, Green, Blue)

The set of 2^15 possible colors that the system is capable of displaying is called its palette, so the palette for this system is 32K colors

Since LUT has only 64 bits index, so it can only show 64 different color at a time on the screen.

Page 8: Computer Graphics Raster Devices Transformations

Indexed Color

Page 9: Computer Graphics Raster Devices Transformations

Coordinates Translation

Usually the upside-down coordinates of raster displays are translated to a more familiar coordinates (Cartesian Coordinates) in programming languages, such as OpenGL.

x

y

(0, 0)

Page 10: Computer Graphics Raster Devices Transformations

Transformations

Transformations are very useful in computer graphics in a number of situations:

A scene can be fashioned by placing a number of instances of an object at different places and with different sizes using proper transformation.

A single motif can be designed and then fashion the whole shape of an object by reflection, rotation, and translation of the motif. (ex. Snowflake)

Helps a designer to view an object from different vantage points and make a picture from each one.

In a computer animation, several objects must move relative to one another from frame to frame.

Page 11: Computer Graphics Raster Devices Transformations

Transformations

A transformation alters each point P in space (2D or 3D) into a new point Q by means of a specific formula or algorithm.

An arbitrary point P in the plane is mapped to another point Q. We say that Q is the image of P under the mapping T.

An object is being transformed by transforming each of its points using the same function T(P) for each point.

Points are represented as:

P

Px

Py

1

Q

Qx

Qy

1

P

Q=T(P)

y

xz

P

Q=T(P)

y

x

Page 12: Computer Graphics Raster Devices Transformations

Affine (or Linear) Transformations

Types of Affine Transformations:

Translation Scaling

Reflection Rotation

An affine transformation is represented by matrices.

Page 13: Computer Graphics Raster Devices Transformations

Translation

Translates a picture into a different position on a graphics display. The translation part of the affine transformation arises from the third column

of the matrix for 2D and forth column for 3D.2D 3D

Qx

Qy

1

1

0

0

0

1

0

A

B

1

Px

Py

1

Qx

Qy

1

Px A

Py B

1

1

0

0

0

0

1

0

0

0

0

1

0

A

B

C

1

1

0

0

0

1

0

A

B

1

Example: 2D translation

Page 14: Computer Graphics Raster Devices Transformations

Scaling

Changes the size of a picture and involves two scale factors Sx and Sy for the x- and y-coordinates

(Qx, Qy) = (SxPx, SyPy)

Thus, the matrix for scaling is simply:

Sx

0

0

0

Sy

0

0

0

1

Sx

0

0

0

Sy

0

0

0

1

Px

Py

1

SxPx

SyPy

1

Example:

Sx

0

0

0

0

Sy

0

0

0

0

Sz

0

0

0

0

1

2D3D

Page 15: Computer Graphics Raster Devices Transformations

Reflection

If a scale factor is negative, then there is also a reflection about a coordinate axis.

1

0

0

0

1

0

0

0

1

About x-axis

1

0

0

0

1

0

0

0

1

About y-axis

P

Q=T(P)

Example: reflection about x-axis x

Page 16: Computer Graphics Raster Devices Transformations

2D Rotation

The rotation of a figure about a given point through some angle.

The matrix for 2D rotation about origin:

Example: P=(x, y) and

cos ( )

sin ( )

0

sin ( )

cos ( )

0

0

0

1

cos ( )

sin ( )

0

sin ( )

cos ( )

0

0

0

1

x

y

1

xcos ( ) ysin ( )

xsin ( ) ycos ( )

1

60

Q=T(P)

P

60

Page 17: Computer Graphics Raster Devices Transformations

3D Rotation

The 3D rotation matrices about each coordinate:

1

0

0

0

0

cos ( )

sin ( )

0

0

sin ( )

cos ( )

0

0

0

0

1

About x-axis (x-roll)

cos ( )

0

sin ( )

0

0

1

0

0

sin ( )

0

cos ( )

0

0

0

0

1

About y-axis (y-roll)

cos ( )

sin ( )

0

0

sin ( )

cos ( )

0

0

0

0

1

0

0

0

0

1

About z-axis (z-roll)

Page 18: Computer Graphics Raster Devices Transformations

Rotation about an arbitrary point

The result of this rotation will be product of three matrices.Step 1) Translation (a, b) to (0, 0)

Step 2) Rotation point P about origin (0, 0)

Step 3) Translation (0, 0) to (a, b)

Example: (a, b) is an arbitrary point and P=(x, y)

1

0

0

0

1

0

a

b

1

cos ( )

sin ( )

0

sin ( )

cos ( )

0

0

0

1

1

0

0

0

1

0

a

b

1

x

y

1

T P( )

Step 1Step 2Step 3

(a, b)

T(P)=Q

P

(0,0)

Page 19: Computer Graphics Raster Devices Transformations

References

Computer Graphics – Using OpenGL

F.S Hill, Jr