Line Drawing and Clipping Week 1, Lecture 2

Similar documents
U.C. Berkeley CS294: Beyond Worst-Case Analysis Luca Trevisan September 5, 2017

Review of Taylor Series. Read Section 1.2

Chapter Newton s Method

Section 8.3 Polar Form of Complex Numbers

Machine learning: Density estimation

Economics 101. Lecture 4 - Equilibrium and Efficiency

Mathematics Intersection of Lines

Ensemble Methods: Boosting

The path of ants Dragos Crisan, Andrei Petridean, 11 th grade. Colegiul National "Emil Racovita", Cluj-Napoca

This model contains two bonds per unit cell (one along the x-direction and the other along y). So we can rewrite the Hamiltonian as:

MTH 263 Practice Test #1 Spring 1999

Lossy Compression. Compromise accuracy of reconstruction for increased compression.

Modeling curves. Graphs: y = ax+b, y = sin(x) Implicit ax + by + c = 0, x 2 +y 2 =r 2 Parametric:

College of Computer & Information Science Fall 2009 Northeastern University 20 October 2009

Week3, Chapter 4. Position and Displacement. Motion in Two Dimensions. Instantaneous Velocity. Average Velocity

Module 2. Random Processes. Version 2 ECE IIT, Kharagpur

Homework Assignment 3 Due in class, Thursday October 15

Chapter 11: Simple Linear Regression and Correlation

CS 2750 Machine Learning. Lecture 5. Density estimation. CS 2750 Machine Learning. Announcements

A 2D Bounded Linear Program (H,c) 2D Linear Programming

Affine transformations and convexity

Correlation and Regression. Correlation 9.1. Correlation. Chapter 9

Chapter 5. Solution of System of Linear Equations. Module No. 6. Solution of Inconsistent and Ill Conditioned Systems

CHAPTER 5 NUMERICAL EVALUATION OF DYNAMIC RESPONSE

18.1 Introduction and Recap

Chapter 8 SCALAR QUANTIZATION

The Geometry of Logit and Probit

Physics 207: Lecture 20. Today s Agenda Homework for Monday

CSci 6974 and ECSE 6966 Math. Tech. for Vision, Graphics and Robotics Lecture 21, April 17, 2006 Estimating A Plane Homography

Linear Feature Engineering 11

Turing Machines (intro)

Digital Signal Processing

Integrals and Invariants of Euler-Lagrange Equations

Least Squares Fitting of Data

Bézier curves. Michael S. Floater. September 10, These notes provide an introduction to Bézier curves. i=0

12. The Hamilton-Jacobi Equation Michael Fowler

Chapter 3 Describing Data Using Numerical Measures

Spectral Graph Theory and its Applications September 16, Lecture 5

Workshop: Approximating energies and wave functions Quantum aspects of physical chemistry

Chapter 9: Statistical Inference and the Relationship between Two Variables

Min Cut, Fast Cut, Polynomial Identities

PART 8. Partial Differential Equations PDEs

Section 8.1 Exercises

The Study of Teaching-learning-based Optimization Algorithm

Solutions to exam in SF1811 Optimization, Jan 14, 2015

Problem Do any of the following determine homomorphisms from GL n (C) to GL n (C)?

Double Layered Fuzzy Planar Graph

Unit 5: Quadratic Equations & Functions

Some Inequalities Between Two Polygons Inscribed One in the Other

One Dimension Again. Chapter Fourteen

CIS526: Machine Learning Lecture 3 (Sept 16, 2003) Linear Regression. Preparation help: Xiaoying Huang. x 1 θ 1 output... θ M x M

Here is the rationale: If X and y have a strong positive relationship to one another, then ( x x) will tend to be positive when ( y y)

MATH 829: Introduction to Data Mining and Analysis The EM algorithm (part 2)

Lecture Notes on Linear Regression

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Lecture 21: Numerical methods for pricing American type derivatives

Stanford University CS359G: Graph Partitioning and Expanders Handout 4 Luca Trevisan January 13, 2011

Introduction to Vapor/Liquid Equilibrium, part 2. Raoult s Law:

Formulas for the Determinant

Calculation of time complexity (3%)

Statistical Mechanics and Combinatorics : Lecture III

Error Bars in both X and Y

Supplement: Proofs and Technical Details for The Solution Path of the Generalized Lasso

Generalized Linear Methods

Lecture 5 Decoding Binary BCH Codes

CALCULUS CLASSROOM CAPSULES

Lecture 2 Solution of Nonlinear Equations ( Root Finding Problems )

Suggested solutions for the exam in SF2863 Systems Engineering. June 12,

COMPLEX NUMBERS AND QUADRATIC EQUATIONS

ˆ (0.10 m) E ( N m /C ) 36 ˆj ( j C m)

Maximal Margin Classifier

EN40: Dynamics and Vibrations. Homework 4: Work, Energy and Linear Momentum Due Friday March 1 st

Bezier curves. Michael S. Floater. August 25, These notes provide an introduction to Bezier curves. i=0

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

(2mn, m 2 n 2, m 2 + n 2 )

PHYS 705: Classical Mechanics. Calculus of Variations II

VQ widely used in coding speech, image, and video

Mechanics Physics 151

Tutorial 2. COMP4134 Biometrics Authentication. February 9, Jun Xu, Teaching Asistant

Celestial Mechanics. Basic Orbits. Why circles? Tycho Brahe. PHY celestial-mechanics - J. Hedberg

1 GSW Iterative Techniques for y = Ax

MLE and Bayesian Estimation. Jie Tang Department of Computer Science & Technology Tsinghua University 2012

Report on Image warping

1. Inference on Regression Parameters a. Finding Mean, s.d and covariance amongst estimates. 2. Confidence Intervals and Working Hotelling Bands

The Second Anti-Mathima on Game Theory

: Numerical Analysis Topic 2: Solution of Nonlinear Equations Lectures 5-11:

THE CHINESE REMAINDER THEOREM. We should thank the Chinese for their wonderful remainder theorem. Glenn Stevens

11. Dynamics in Rotating Frames of Reference

Chapter 3. r r. Position, Velocity, and Acceleration Revisited

Grover s Algorithm + Quantum Zeno Effect + Vaidman

Statistics MINITAB - Lab 2

ANOVA. The Observations y ij

Kernel Methods and SVMs Extension

= 1.23 m/s 2 [W] Required: t. Solution:!t = = 17 m/s [W]! m/s [W] (two extra digits carried) = 2.1 m/s [W]

The Second Eigenvalue of Planar Graphs

Single Variable Optimization

Spatial Statistics and Analysis Methods (for GEOG 104 class).

MA 323 Geometric Modelling Course Notes: Day 13 Bezier Curves & Bernstein Polynomials

A New Algorithm for Finding a Fuzzy Optimal. Solution for Fuzzy Transportation Problems

Multilayer Perceptron (MLP)

Transcription:

CS 43 Computer Graphcs I Lne Drawng and Clppng Week, Lecture 2 Davd Breen, Wllam Regl and Maxm Peysakhov Geometrc and Intellgent Computng Laboratory Department of Computer Scence Drexel Unversty http://gcl.mcs.drexel.edu Outlne Lne drawng Dgtal dfferental analyzer Bresenham s algorthm lne clppng Parametrc lne clppng 2 Scan-Converson Algorthms Scan-Converson: Computng pxel coordnates for deal lne on 2D raster grd Pxels best vsualzed as crcles/dots Why? Montor hardware 3 Dgtal Dfferental Analyzer (DDA) If slope s less then _x = (otherwze _y = ) Compute correspondng _y (_x) x k+ = x k + _x y k+ = y k + _y Issues: Avodng floatng pont ops, multplcatons, and real numbers y k+ y k _y _x x k x k+ 4 965 @ IBM Basc Idea: Only nteger arthmetc Incremental Consder the mplct equaton for a lne: 5 Gven: mplct lne equaton: Let: where r and q are ponts on the lne Then: Observe that all of these are ntegers and: for ponts above the lne for ponts below the lne Now.. 6

Suppose we just fnshed (assume <slope<) other cases symmetrc Whch pxel next? E or NE 7 Assume: = exact y value at y mdway between E and NE: Observe: If, then pck E Else pck NE If, t doesn t matter 8 Create modfed mplct functon (2x) Create a decson varable D to select, where D s the value of f at the mdpont: If then m s below the lne NE s the closest pxel If then m s above the lne E s the closest pxel 9 Note: because we multpled by 2x, D s now an nteger---whch s very good news How do we make ths ncremental?? Case I: When E s next What ncrement for computng an new D? Next mdpont s: Case II: When NE s next What ncrement for computng an new D? Next mdpont s: Hence, ncrement by: Hence, ncrement by: 2 2

How to get an ntal value for D? The Algorthm Suppose we start at: Intal mdpont s: Then: Assumptons: 3 Pre-computed: 4 5 6 7 8 3

9 2 2 22 23 Some ssues wth s Pxel densty vares based on slope straght lnes look darker, more pxels per CM Endpont order Lne from P to P2 should match P2 to P Always choose E when httng M, regardless of drecton 24 4

Some ssues wth s How to handle the lne when t hts the clp wndow? Vertcal ntersectons Could change lne slope Need to change nt cond. Horzontal ntersectons Agan, changes n the boundary condtons Can t just ntersect the lne w/ the box 25 Scssorng Clppng Performed durng scan converson of the lne (crcle, polygon) Compute the next pont (x,y) If x mn x x max and y mn y y max Then output the pont. Else do nothng Issues wth scssorng: Too slow Does more work then necessary We are not gong to use t. 26 The Lne Clppng Algorthm How to clp lnes to ft n wndows? easy to tell f whole lne falls w/n wndow harder to tell what part falls nsde Consder a straght lne And wndow: 27 Basc Idea: Frst, do easy test completely nsde or outsde the box? If no, we need a more complex test Note: we wll also need to fgure out how scan lne meets the box 28 The Easy Test: Compute 4-bt code based on endponts P and P 2 Lne s completely vsble ff both code values of endponts are,.e. If lne segments are completely outsde the wndow, then 29 3 5

Otherwse, we clp the lnes: We know that there s a bt flp, w.o.l.g. assume ts (x,x ) Whch bt? Try `em all! suppose ts bt 4 Then x < WL and we know that x WL We need to fnd the pont: (x c,y c ) 3 Clearly: Usng smlar trangles Solvng for y c gves 32 Replace (x,y ) wth (x c,y c ) Re-compute values Contnue untl all ponts are nsde the clp wndow QED 33 Parametrc Lne Clppng Developed by Cyrus and Beck n 978 Used to clp 2D/3D lnes aganst convex polygon/polyhedron Lang and Barsky (984) algorthm effcent n clppng uprght 2D/3D clppng regons Frst we wll follow orgnal Cyrus-Beck development to ntroduce parametrc clppng Then we wll reduce Cyrus-Beck to more effcent Lang-Barsky case 34 The Cyrus-Beck Technque algorthm computes (x,y) ntersectons of the lne and clppng edge Cyrus-Beck fnds a value of parameter t for ntersectons of the lne and clppng edges Smple comparsons used to fnd actual ntersecton ponts Lang-Barsky optmzes t by examnng t values as they generated to reject some lne segments mmedately 35 Fndng the Intersecton Ponts Lne P(t) = P +t(p -P ) Pont on the edge P E N [P(t)-P ] = N [P + t(p-p )-P ] = N [P -P ] + N t[p-p ] = E E Let D = (P-P ) N [P - PE ] t = - N D Make sure. D, or P P 2. N D lnes are not parallel E 36 6

Fndng the Lne Segment Classfy pont as potentally enterng (PE) or leavng (PL) PE f crosses edge nto nsde half plane => angle P P and N greater 9 => N D < PL otherwse. Fnd T e = max(t e ) Fnd T l = mn(t l ) Dscard f T e > T l If T e < T e = If T l > T l = Use T e, T l to compute ntersecton coordnates (x e,y e ), (x l,y l ) 37 7