Points and lines. x x 1 + y 1. y = mx + b

Similar documents
Section Graphs and Lines

1 Introduction to Graphics

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

Computer Graphics D Graphics Algorithms

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Sec 4.1 Coordinates and Scatter Plots. Coordinate Plane: Formed by two real number lines that intersect at a right angle.

Chapter 12: Quadratic and Cubic Graphs

Did You Find a Parking Space?

Rasterization: Geometric Primitives

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Example 1: Give the coordinates of the points on the graph.

Chapter - 2: Geometry and Line Generations

Graphing Linear Equations

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

Chapter 8: Implementation- Clipping and Rasterization

RASTERIZING POLYGONS IN IMAGE SPACE

Review for Mastery Using Graphs and Tables to Solve Linear Systems

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Section 18-1: Graphical Representation of Linear Equations and Functions

Chapter 1. Linear Equations and Straight Lines. 2 of 71. Copyright 2014, 2010, 2007 Pearson Education, Inc.

Computer Graphics D Graphics Algorithms

Intro. To Graphing Linear Equations

Rasterization, or What is glbegin(gl_lines) really doing?

Line Drawing Week 6, Lecture 9

UNIT -8 IMPLEMENTATION

UNIT 2 GRAPHIC PRIMITIVES

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

Line Drawing. Foundations of Computer Graphics Torsten Möller

From Ver(ces to Fragments: Rasteriza(on

The x-intercept can be found by setting y = 0 and solving for x: 16 3, 0

(Refer Slide Time: 00:03:51)

Vocabulary Unit 2-3: Linear Functions & Healthy Lifestyles. Scale model a three dimensional model that is similar to a three dimensional object.

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

Introduction to Computer Graphics (CS602) Lecture 05 Line Drawing Techniques

Revision Topic 11: Straight Line Graphs

Practice Test (page 391) 1. For each line, count squares on the grid to determine the rise and the run. Use slope = rise

WRITING AND GRAPHING LINEAR EQUATIONS ON A FLAT SURFACE #1313

GRAPHING WORKSHOP. A graph of an equation is an illustration of a set of points whose coordinates satisfy the equation.

The Rectangular Coordinate System and Equations of Lines. College Algebra

Test Name: Chapter 3 Review

3-6 Lines in the Coordinate Plane

Einführung in Visual Computing

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

QUADRATIC AND CUBIC GRAPHS

Direction Fields; Euler s Method

graphing_9.1.notebook March 15, 2019

CS 130. Scan Conversion. Raster Graphics

SNAP Centre Workshop. Graphing Lines

Section 4.4: Parabolas

State the domain and range of the relation. EX: {(-1,1), (1,5), (0,3)} 1 P a g e Province Mathematics Southwest TN Community College

MODULE - 4. e-pg Pathshala

Math 1313 Prerequisites/Test 1 Review

Advanced Algebra. Equation of a Circle

You should be able to plot points on the coordinate axis. You should know that the the midpoint of the line segment joining (x, y 1 1

Section 7D Systems of Linear Equations

1.1 - Functions, Domain, and Range

UNIT 3B CREATING AND GRAPHING EQUATIONS Lesson 4: Solving Systems of Equations Instruction

(Refer Slide Time: 00:02:02)

Graphics (Output) Primitives. Chapters 3 & 4

An Improved Algorithm for Scan-converting a Line

Forms of Linear Equations

Lesson 19: The Graph of a Linear Equation in Two Variables is a Line

Graphing Linear Equations

Functions. Copyright Cengage Learning. All rights reserved.

slope rise run Definition of Slope

Overview of Computer Graphics

GRAPHICS OUTPUT PRIMITIVES

(Refer Slide Time: 9:36)

3.1. 3x 4y = 12 3(0) 4y = 12. 3x 4y = 12 3x 4(0) = y = x 0 = 12. 4y = 12 y = 3. 3x = 12 x = 4. The Rectangular Coordinate System

Scan Converting Lines

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

Section 2.2 Graphs of Linear Functions

CPSC / Scan Conversion

COMP371 COMPUTER GRAPHICS

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

CS 543: Computer Graphics. Rasterization

Math-2. Lesson 3-1. Equations of Lines

FLC Ch 3. Ex 1 Plot the points Ex 2 Give the coordinates of each point shown. Sec 3.2: Solutions and Graphs of Linear Equations

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

A function: A mathematical relationship between two variables (x and y), where every input value (usually x) has one output value (usually y)

Section 1.1 The Distance and Midpoint Formulas

Efficient Plotting Algorithm

Graphing Linear Equations and Inequalities: Graphing Linear Equations and Inequalities in One Variable *


HFCC Math Lab Intermediate Algebra 1 SLOPE INTERCEPT AND POINT-SLOPE FORMS OF THE LINE

Four Types of Slope Positive Slope Negative Slope Zero Slope Undefined Slope Slope Dude will help us understand the 4 types of slope

Raster Scan Displays. Framebuffer (Black and White)

1.1 - Functions, Domain, and Range

x 16 d( x) 16 n( x) 36 d( x) zeros: x 2 36 = 0 x 2 = 36 x = ±6 Section Yes. Since 1 is a polynomial (of degree 0), P(x) =

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Middle School Math Course 3

Types of Edges. Why Edge Detection? Types of Edges. Edge Detection. Gradient. Edge Detection

Topic. Section 4.1 (3, 4)

7.3 3-D Notes Honors Precalculus Date: Adapted from 11.1 & 11.4

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

UNIT 4 DESCRIPTIVE STATISTICS Lesson 2: Working with Two Categorical and Quantitative Variables Instruction

Name Period Date LINEAR FUNCTIONS STUDENT PACKET 2: MULTIPLE REPRESENTATIONS 2

Assignment Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading.

Raster Displays and Scan Conversion. Computer Graphics, CSCD18 Fall 2008 Instructor: Leonid Sigal

Transcription:

Points and lines Point is the fundamental element of the picture representation. It is nothing but the position in a plan defined as either pairs or triplets of number depending on whether the data are two or three dimensional. Thus, (x 1,y 1 ) or (x 1,y 1,z 1 ) would represent a point in either two three dimensional space. Two points would represent a line or edge, and a collection of three or more points a polygon. The representation of curved lines is usually accomplished by approximating them by short straight line segments. If the two points used to specify a line are (x 1,y 1 ) and (x 2,y 2 ), then an equation for the line is given as y y 1 x x 1 = y 2 y 1 x 2 x 1 y = y 2 y 1 x 2 x 1 x x 1 + y 1 y = mx + b where m = y 2 y 1 x 2 x 1 and b= y 1 m x 1 The above equation is called the slop intercept form of the line. The slope m is the change in height (y 2- y 1 ) divided by the change in the width (x 2 -x 1 ) for two points on the line. The intercept b is the height at which the line crosses the y-axis. We can determine whether two lines are crossing or parallel. When two lines cross, they share some point in common. Of course, that point satisfies equations for the two lines. Let us see how to obtain this point. Consider two lines having slops m 1 and m 2 and y-intercepts b 1 and b 2 respectively. Then we can write the equations for these two lines as, Line 1: y = m 1 x + b 1 Line 2: y = m 2 x + b 2 If point (x p,y p ) is shared by both lines, then it should satisfy the last two equations y p = m 1 xp + b 1 and y p = m 2 xp + b 2 Equating the above equations gives, m 1 x p + b 1 = m 2 x p + b 2 1

x p m 1 m 2 = b 2 b 1 x p = b 2 b 1 Substituting this into equation for line 1 or for line 2 gives, y p =m 1 Therefore, the point b 2 b 1 + b 1 y p = m 1 (b 2 b 1 )+ b 1 ( ) y p = m 1 b 2 b 1 m 2 b 2 b 1, m 1 b 2 b 1 m 2 is the point of intersection. If the two lines are parallel, they have the same slope. In the expression for the point of intersection, m 1 = m 2. So the denominator becomes zero. So the expression results in a divide by zero. This means, there is no point of intersection for the parallel lines. Line Drawing Algorithms The process of turning on the pixels for a line segment is called vector generation or line generation, and the algorithms for them are known as vector generation algorithms or line drawing algorithms. Before discussing specific line drawing algorithms it is useful to note the general requirements for such algorithms. These requirements specify the desired characteristics of line. The line should appear as a straight line and it should start and end accurately. The line should be displayed with constant brightness along its length independent of its length and orientation. The line should be drawn rapidly. Let us see the different lines drawn in fig bellow, Vertical and Horizontal lines 45 line 2

???? Line with other orientation As shown in the figure, horizontal and vertical lines are straight and have same width. The 45 line is straight, but its width is not constant. On the other hand, the line with any other orientation is neither straight nor has same width. Such cases are due to the finite resolution of display and we have to accept approximate pixels in such situation. The brightness of the line is dependent on the orientation of the line. We can observe that the effective spacing between pixels for the 45 line is greater than for the vertical and horizontal lines. This will make the vertical and horizontal lines appear brighter than the 45 line. Complex calculations are required to provide equal brightness along lines of varying length and orientation. Vector Generation/Digital Differential Analyzer (DDA) line algorithm 1. Read the line end points (x 1,y 1 ) and (x 2,y 2 ) such that they are not equal. [if equal then plot that point and exit ] 2. x = x 2 x 1 and y = y 2 y 1 3. If ( x y) then Length= x else Length= y end if 4. x = (x 2 x 1 )/length y = (y 2 y 1 )/length [This makes either x or y equal to 1 because length is either x 2 x 1 or y 2 y 1. Therefore, the incremental value for either x or y is one.] 3

5. x = x 1 + 0.5 sign( x) Y = y 1 + 0.5 sign( y) [Here, sign function makes the algorithm work in all quadrants. It returns -1, 0, 1 depending on whether its argument is <0, =0, >0, respectively.] 6. i=1 [begins the loop, in this points are plotted] While (i length) { Plot (integer(x), integer(y)) x = x + x y = y + y i = i + 1 } Stop Example 1: consider the line from (0,0) to (6,6). Use the simple DDA algorithm to rasterize this line Solution: x 1 =0 y 1 =0 x 2 =6 y 2 =6 Length = y 2 y 1 = x 2 x 1 =6 x = (x 2 x 1 )/length = 6/6 = 1 and y = (y 2 y 1 )/length =6/6 = 1 Initial value for x = 0 + 0.5 sign(1) =0.5 Y = 0 + 0.5 sign(1)= 0.5 I plot x y 0.5 0.5 1 (0,0) 1.5 1.5 2 (1,1) 2.5 2.5 3 (2,2) 3.5 3.5 4 (3,3) 4.5 4.5 4

I plot x y 5 (4,4) 5.5 5.5 6 (5,5) 6.5 6.5 The results are plotted as shown 5 0 0 5 Example 2: consider the line from (0,0) to (4,6). Use the simple DDA algorithm to rasterize this line Solution: x 1 =0 y 1 =0 x 2 =4 y 2 =6 Length = y 2 y 1 =6 x = (x 2 x 1 )/length = 4/6 and y = (y 2 y 1 )/length =6/6 = 1 Initial value for x = 0 + 0.5 sign(4/6) =0.5 Y = 0 + 0.5 sign(1)= 0.5 I plot x y 0.5 0.5 1 (0,0) 1.167 1.5 2 (1,1) 1.833 2.5 5

I plot x y 3 (1,2) 4 (2,3) 5 (3,4) 6 (3,5) 2.5 3.5 3.167 4.5 3.833 5.5 4.5 6.5 The results are plotted as shown 5 0 0 5 Advantages of DDA Algorithm 1. It is the simplest algorithm and it does not require special skills for implementation. 2. It is a faster method for calculating pixel positions than the direct use of equation y = mx + b. It eliminates the multiplication in the equation by making use of raster characteristics, so that appropriate increments are applied in the x or y direction to find the pixel positions along the line path. Disadvantages of DDA Algorithm 1. Floating point arithmetic in DDA algorithm is still time-consuming. 2. The algorithm is orientation dependent. So the end point accuracy is poor. 6