lecture2 - WHERE TO DRAW A LINE?? Line drawing is...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: WHERE TO DRAW A LINE?? Line drawing is accomplished by calculating intermediate positions along the line path between specified end points. Precise definition of line drawing Given two points P and Q in the plane, both with integer coordinates, determine which pixels on a raster screen should be on in order to make a picture of a unit-width line segment starting from P and ending at Q. 0 1 2 3 4 5 6 6 5 4 3 2 1 (3, 3) Line drawing (cont) The thinnest line is of one-pixel wide. We will concentrate on drawing a line of 1 pixel resolution. The Cartesian slope-intercept equation for a straight line is y= m. x + b m is the slope of the line and b is the y intercept. Given the endpoints of a line segment. m = y2-y1 / x2-x1 b= y1-m.x1 Line Drawing (cont) Also for any given interval x along a line, we can compute the corresponding y interval y from y= m. x Similarly we can obtain the x interval x corresponding to a specified y as x= y / m These equations form the basis for determining deflection voltages in analog devices. Line Drawing (cont) Also , for any given x interval x along a line, we can compute the corresponding y interval y from y= m. x These equations form the basis for determining deflection voltages in analog devices. On Raster systems, lines are plotted with pixels, and step sizes in the horizontal and vertical directions are constrained by pixel separations. Hence we ought to sample a line at discrete positions and determine the nearest pixel to the line at each sampled position. Symmetry If we could draw lines with positive slope (0<=slope<=1) we would be done. For a line with negative slope (0>=slope>=-1) We negate all Y values For a line with slope > 1 or slope <-1 we just swap x and y axes 45 (y,x) (x,y) (x,-y) (y,-x) (-y,x) (x,-y) (-x,-y) (-y,-x) Code for drawing a line Invert_y_draw ( int x,int y ) draw_pixel(x,-y) Swap_xy_draw ( int x,int y )...
View Full Document

This note was uploaded on 04/05/2010 for the course COMPUTER S 876 taught by Professor Ch during the Spring '10 term at Amirkabir University of Technology.

Page1 / 38

lecture2 - WHERE TO DRAW A LINE?? Line drawing is...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online