cg - output primitives

Post on 06-May-2015

2.961 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Output Primitives

Organized By: Vinay Arora

Assistant Professor, CSED

Thapar University, Patiala

Vinay Arora

CSED

Disclaimer

This is NOT A COPYRIGHT MATERIAL

Content has been taken mainly from the following books & websites:

Computer Graphics C Version By Donald Hearn, M. Pauline BakerSchaum's outline of theory and problems of computer graphics By Zhigang Xiang, Roy A. Plastock

Computer Graphics: Principles and Practice By James D. Foley

http://en.wikipedia.org/wiki/Computer_graphics

http://www.howstuffworks.com/3dgraphics.htm

http://www.graphics.cornell.edu/online/tutorial/

http://www.cgarena.com/

etc…

Vinay Arora

CSED

Object Model

Vinay Arora

CSED

Primitives

� 2-D Drawing or a 3-D Object consist of Graphical Primitives such as

Points, Lines, Circles & Filled Polygons.

� Graphics System or the Application Program convert each primitive

from its geometric definition into a set of Pixels that make up the

primitive in the Image Space.

� This Conversion is referred to as SCAN CONVERSION or

RASTERIZATION.

Vinay Arora

CSED

Definitions

� RASTERIZATION: Process of determining which pixels provide the best

approximation to a desired line on the screen.

� SCAN CONVERSION: Combination of rasterization and generating the

picture in scan line order.

Vinay Arora

CSED

General Requirement

� Straight lines must appear as straight lines.

� They must start and end accurately.

� Lines should have constant brightness along their length.

� Lines should drawn rapidly.

Vinay Arora

CSED

Straight lines must appear as Straight

Lines

Vinay Arora

CSED

� For horizontal, vertical and 45º lines, the choice of raster elements is

obvious. This lines exhibit constant brightness along the length:

Vinay Arora

CSED

� For any other orientation the choice is more difficult:

Vinay Arora

CSED

Intersection Points

� In general Line doesn’t pass through Intersection Points.

� Points are very close & dense that’s why – it appears as Straight Line.

� We have to find Addressable Pixels.

� Points Distributed over the line & the most closest to the line.

� No Addressable Pixel is having any Floating Point number/value.

Vinay Arora

CSED

Jaggies

Vinay Arora

CSED

Staircase Effect

Vinay Arora

CSED

Staircase Effect

Vinay Arora

CSED

Direct Scan Conversion

Vinay Arora

CSED

DDA – Digital Differential Analyzer

Vinay Arora

CSED

DDA – Pseudo code

Vinay Arora

CSED

Section of Display Screen in case of Positive

Slope Line

Vinay Arora

CSED

Section of Display Screen in case of

Negative Slope Line

Vinay Arora

CSED

Screen Grid showing a Pixel in column xk on scan line yk that is to be

plotted along the path of line with slope 0 < m <1

Vinay Arora

CSED

Distance between pixel positions & the line y

coordinate at sampling position xk+1

Vinay Arora

CSED

Bresenham’s Algorithm

They coordinate on mathematical line at pixel column position xk+l is calculated as

Vinay Arora

CSED

Bresenham’s Algorithm (Conti…)

where term yk+1 - yk is either 0 or 1, depending on the sign of parameter pk.

Vinay Arora

CSED

Algorithm

Vinay Arora

CSED

Line Drawing

Vinay Arora

CSED

Example

Vinay Arora

CSED

Solution

Vinay Arora

CSED

Representation of Circle

Vinay Arora

CSED

Representation of Circle

Vinay Arora

CSED

Mid Point Representation

Vinay Arora

CSED

Mid Point Representation

Vinay Arora

CSED

Mid Point Circle Algo. – Basic Steps

Vinay Arora

CSED

Mid Point Circle Algo. – Basic Steps

Vinay Arora

CSED

Mid Point Circle Algo. – Basic Steps

Vinay Arora

CSED

Mid Point Circle Algorithm

Vinay Arora

CSED

Mid Point Circle Algorithm (Contd)

Vinay Arora

CSED

Example

Vinay Arora

CSED

Ellipse

Vinay Arora

CSED

Ellipse (Contd.)

Vinay Arora

CSED

General Equation

Vinay Arora

CSED

Scan Converting an Ellipse

Vinay Arora

CSED

Equation for Ellipse

Vinay Arora

CSED

Equation for Ellipse – For Region 1

Vinay Arora

CSED

Scan Line for Polygon Filling

Vinay Arora

CSED

Scan Line for Polygon Filling

Vinay Arora

CSED

Selecting Vertex

Vinay Arora

CSED

Formula for Next Value for x

Vinay Arora

CSED

Saving Intersection Points

Vinay Arora

CSED

Color Boundaries for Boundary Fill

Procedure

Vinay Arora

CSED

4-Connected & 8-Connected

Vinay Arora

CSED

Boundary Fill Algorithm

Vinay Arora

CSED

Partially Filled in 4 - Connected

Vinay Arora

CSED

Boundary Fill across Pixel spans for a

4 – connected area

Vinay Arora

CSED

Boundary Fill across Pixel spans for a

4 – connected area

Vinay Arora

CSED

Flood Fill

Vinay Arora

CSED

Flood Fill Algorithm

Vinay Arora

CSED

Thnx…

top related