Picking and Curves Week 6

Similar documents
CS 4204 Computer Graphics

Curves and Surfaces. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

OUTLINE. Quadratic Bezier Curves Cubic Bezier Curves

Until now we have worked with flat entities such as lines and flat polygons. Fit well with graphics hardware Mathematically simple

Computer Graphics. Curves and Surfaces. Hermite/Bezier Curves, (B-)Splines, and NURBS. By Ulf Assarsson

EECS 487: Interactive Computer Graphics f

Hardware-Accelerated Free-Form Deformation

Today. B-splines. B-splines. B-splines. Computergrafik. Curves NURBS Surfaces. Bilinear patch Bicubic Bézier patch Advanced surface modeling

Better Interactive Programs. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Curve Modeling (Spline) Dr. S.M. Malaek. Assistant: M. Younesi

Bias of Higher Order Predictive Interpolation for Sub-pixel Registration

Splines Computer Graphics I Lecture 10

Summer 2017 MATH Suggested Solution to Exercise Find the tangent hyperplane passing the given point P on each of the graphs: (a)

COMPOSITION OF STABLE SET POLYHEDRA

Curves and Surfaces 1

Bezier Curves, B-Splines, NURBS

Reading. 13. Texture Mapping. Non-parametric texture mapping. Texture mapping. Required. Watt, intro to Chapter 8 and intros to 8.1, 8.4, 8.6, 8.8.

Blended Deformable Models

Reading. 11. Texture Mapping. Texture mapping. Non-parametric texture mapping. Required. Watt, intro to Chapter 8 and intros to 8.1, 8.4, 8.6, 8.8.

Advanced Computer Graphics (CS & SE )

Continuity Smooth Path Planning Using Cubic Polynomial Interpolation with Membership Function

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

On the Computational Complexity and Effectiveness of N-hub Shortest-Path Routing

Design considerations

Intro to Curves Week 4, Lecture 7

Tu P7 15 First-arrival Traveltime Tomography with Modified Total Variation Regularization

Multi-lingual Multi-media Information Retrieval System

5 Performance Evaluation

Image Denoising Algorithms

Intro to Curves Week 1, Lecture 2

CS 450: COMPUTER GRAPHICS REVIEW: CLIPPING SPRING 2015 DR. MICHAEL J. REALE

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2

A sufficient condition for spiral cone beam long object imaging via backprojection

CS130 : Computer Graphics Curves. Tamar Shinar Computer Science & Engineering UC Riverside

Evaluating Influence Diagrams

Curves and Surfaces Computer Graphics I Lecture 9

Curves and Surface I. Angel Ch.10

Tdb: A Source-level Debugger for Dynamically Translated Programs

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

CS 153 Design of Operating Systems Spring 18

EMC ViPR. User Guide. Version

Mathematician Helaman Ferguson combines science

Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

10.2 Solving Quadratic Equations by Completing the Square

AUTOMATIC REGISTRATION FOR REPEAT-TRACK INSAR DATA PROCESSING

OPTI-502 Optical Design and Instrumentation I John E. Greivenkamp Homework Set 9 Fall, 2018

Curves and Surfaces Computer Graphics I Lecture 10

POWER-OF-2 BOUNDARIES

Real-time mean-shift based tracker for thermal vision systems

Prof. Kozyrakis. 1. (10 points) Consider the following fragment of Java code:

EXAMINATIONS 2010 END OF YEAR NWEN 242 COMPUTER ORGANIZATION

2D Spline Curves. CS 4620 Lecture 13

Computer Graphics Spline and Surfaces

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

Requirements Engineering. Objectives. System requirements. Types of requirements. FAQS about requirements. Requirements problems

Networks An introduction to microcomputer networking concepts

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

The effectiveness of PIES comparing to FEM and BEM for 3D elasticity problems

3D Modeling Parametric Curves & Surfaces

CS 153 Design of Operating Systems Spring 18

FINITE ELEMENT APPROXIMATION OF CONVECTION DIFFUSION PROBLEMS USING GRADED MESHES

Application of Gaussian Curvature Method in Development of Hull Plate Surface

Review Multicycle: What is Happening. Controlling The Multicycle Design

Computer-Aided Mechanical Design Using Configuration Spaces

Objects 2: Curves & Splines Christian Miller CS Fall 2011

Intro to Modeling Modeling in 3D

The extra single-cycle adders

2D Spline Curves. CS 4620 Lecture 18

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

Know it. Control points. B Spline surfaces. Implicit surfaces

The Intersection of Two Ringed Surfaces and Some Related Problems

ABSOLUTE DEFORMATION PROFILE MEASUREMENT IN TUNNELS USING RELATIVE CONVERGENCE MEASUREMENTS

SZ-1.4: Significantly Improving Lossy Compression for Scientific Data Sets Based on Multidimensional Prediction and Error- Controlled Quantization

11 - Bump Mapping. Bump-Mapped Objects. Bump-Mapped Objects. Bump-Mapped Objects. Limitations Of Texture Mapping. Bumps: Perturbed Normals

CHAPTER 1 Graphics Systems and Models 3

Computer User s Guide 4.0

Central issues in modelling

CS 153 Design of Operating Systems

CS-184: Computer Graphics

Lecture 10. Diffraction. incident

B-spline Curves. Smoother than other curve forms

Readings on Bézier Curves and Surfaces. 1 Additional Reading. 2 Organization. 3 Introduction. 4 Representing Curves

CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Augmenting the edge connectivity of planar straight line graphs to three

Computer Graphics I Lecture 11

The Occlusion Camera

Review. A single-cycle MIPS processor

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Uncertainty Determination for Dimensional Measurements with Computed Tomography

CS-184: Computer Graphics. Today

An Adaptive Strategy for Maximizing Throughput in MAC layer Wireless Multicast

CS 153 Design of Operating Systems

Today s Lecture. Software Architecture. Lecture 27: Introduction to Software Architecture. Introduction and Background of

Functions of Combinational Logic

Interactive Graphics. Lecture 9: Introduction to Spline Curves. Interactive Graphics Lecture 9: Slide 1

Computer Graphics Curves and Surfaces. Matthias Teschner

Seismic trace interpolation with approximate message passing Navid Ghadermarzy and Felix Herrmann and Özgür Yılmaz, University of British Columbia

4.13 Advanced Topic: An Introduction to Digital Design Using a Hardware Design Language 345.e1

Discretized Approximations for POMDP with Average Cost

Transcription:

CS 48/68 INTERACTIVE COMPUTER GRAPHICS Picking and Crves Week 6 David Breen Department of Compter Science Drexel University Based on material from Ed Angel, University of New Mexico

Objectives Picking Select objects from the display Introdce types of crves and srfaces Explicit Implicit Parametric Strengths and weaknesses Discss Modeling and Approximations Conditions Stability 2

Picking Identify a ser-defined object on the display In principle, it shold be simple becase the mose gives the position and we shold be able to determine to which object(s) a position corresponds Practical difficlties Pipeline architectre is feed forward, hard to go from screen back to world Complicated by screen being 2D, world is D How close do we have to come to object to say we selected it?

Three Approaches Hit list Most general approach bt most difficlt to implement Use back or some other bffer to store object ids as the objects are rendered Rectanglar maps Easy to implement for many applications Divide screen into rectanglar regions 4

Using another bffer and colors for picking For a small nmber of objects, we can assign a niqe color (often in color index mode) to each object We then render the scene to a color bffer other than the front bffer so the reslts of the rendering are not visible We then get the mose position and se glreadpixels() to read the color in the bffer we jst wrote at the position of the mose The retrned color gives the id of the object 5

Using Regions of the Screen Many applications se a simple rectanglar arrangement of the screen Example: paint/cad program tools drawing area mens Easier to look at mose position and determine which area of screen it is in that sing selection mode picking 6

Rendering Modes OpenGL can render in one of three modes selected by glrendermode(mode) GL_RENDER: normal rendering to the frame bffer (defalt) GL_FEEDBACK: provides list of primitives rendered bt no otpt to the frame bffer GL_SELECTION: Each primitive in the view volme generates a hit record that is placed in a name stack which can be examined later 7

Hit Record 8

Using Selection Mode Initialize name bffer Enter selection mode (sing mose) Render scene with ser-defined names (id#) Every object in view volme generates a hit Name stack processing always done Reenter normal render mode This operation retrns nmber of hits Examine contents of name bffer (hit records) Hit records inclde nmber of ids, depth information and ids on stack at moment of rendering 9

Selection Mode Fnctions glselectbffer(): specifies name bffer glinitnames(): initializes name bffer glpshname(id): psh id on name bffer glpopname(): pop top of name bffer glloadname(id): replace top name on bffer id is set by application to identify objects Can t be called inside glbegin/glend

Selection Mode and Picking In general, selection mode won t work for picking becase every primitive in the view volme will generate a hit Change the viewing parameters so that only those primitives near the crsor are in the altered view volme Use glpickmatrix

glpickmatrix() glpickmatrix(gldoble x, Gldoble y, Gldoble w, Gldoble h, Glint *vp) k Creates a projection matrix for picking that restricts drawing to a w x h area centered at (x,y) in the window coordinates within the viewport vp 2

Go to pick.c

Introdction to Crves

Escaping Flatland Until now we have worked with flat entities sch as lines and flat polygons Fit well with graphics hardware Mathematically simple Bt the world is not composed of flat entities Need crves and crved srfaces May only have need at the application level Implementation can render them approximately with flat primitives 5

Modeling with Crves data points approximating crve interpolating data point 6

What Makes a Good Representation? There are many ways to represent crves and srfaces Want a representation that is Stable Smooth Easy to evalate Mst we interpolate or can we jst come close to data? Do we need derivatives? 7

Explicit Representation Most familiar form of crve in 2D y=f(x) Cannot represent all crves Vertical lines Circles Extension to D y=f(x), z=g(x) The form z = f(x,y) defines a srface y z x y 8 x

Implicit Representation Two dimensional crve(s) g(x,y)= Mch more robst All lines ax+by+c= Circles x 2 +y 2 -r 2 = Three dimensions g(x,y,z)= defines a srface Intersect two srface to get a crve In general, we cannot solve for points that satisfy the eqation 9

Parametric Crves Separate eqation for each spatial variable x=x() y=y() z=z() For max min we trace ot a crve in two or three dimensions p( min ) p() p()=[x(), y(), z()] T p( max ) 2

Selecting Fnctions Usally we can select good fnctions not niqe for a given spatial crve Approximate or interpolate known data Want fnctions which are easy to evalate Want fnctions which are easy to differentiate Comptation of normals Connecting pieces (segments) Want fnctions which are smooth 2

Parametric Lines We can normalize to be over the interval (,) Line connecting two points p and p p()= p p()=(-)p +p Ray from p in the direction d p()=p +d p() = p p() = p d p()= p +d 22

Crve Segments After normalizing, each crve is written p()=[x(), y(), z()] T, In classical nmerical methods, we design a single global crve In compter graphics and CAD, it is better to design small connected crve segments p() join point p() = q() p() q() q() 2

Parametric Polynomial Crves N i j x( ) = cxi y( ) = c yj z() = c zk i= M j= If N=M=K, we need to determine (N+) coefficients Eqivalently we need (N+) independent conditions K " k k= Noting that the crves for x, y and z are independent, we can define each independently in an identical manner We will se the form where p can be any of x, y, z p() = K " c k k k= 24

Why Polynomials Easy to evalate Continos and differentiable everywhere Mst worry abot continity at join points inclding continity of derivatives p() q() join point p() = q() bt p () q () 25

Cbic Parametric Polynomials N=M=K=, gives balance between ease of evalation and flexibility in design p( ) = k = c k For coefficients to determine for each of x, y and z Seek for independent conditions for varios vales of reslting in 4 eqations in 4 nknowns for each of x, y and z Conditions are a mixtre of continity reqirements at the join points and conditions for fitting the data k 26

Designing Parametric Cbic Crves

Objectives Introdce the types of crves Interpolating Hermite Bezier B-spline Analyze their performance 28

29 Matrix-Vector Form c k k k = = ) p( " # % & = c c c c 2 c " # % & = 2 define c c T T = = ) p( then

Interpolating Crve p p p p 2 Given for data (control) points p, p,p 2, p determine cbic p() which passes throgh them Mst find c,c,c 2, c

Interpolating Mltiple Segments se p = [p p p 2 p ] T se p = [p p 4 p 5 p 6 ] T Get continity at join points bt not continity of derivatives

2 Interpolation Eqations apply the interpolating conditions at =, /, 2/, p =p()=c p =p(/)=c +(/)c +(/) 2 c 2 +(/) c p 2 =p(2/)=c +(2/)c +(2/) 2 c 2 +(2/) c p =p()=c +c +c 2 +c or in matrix form with p = [p p p 2 p ] T p=ac " # % & ' ( ) * +, ' ( ) * +, ' ( ) * +, ' ( ) * +, ' ( ) * +, ' ( ) * +, = 2 2 2 2 2 A

Interpolation Matrix Solving for c we find the interpolation matrix MI = ' A = & ' %' 5.5 9 4.5 9 ' 22.5.5 ' 4.5 8 '.5 # ' 4.5 4.5 " c=m I p Note that M I does not depend on inpt data and can be sed for each segment in x, y, and z

Blending Fnctions Rewriting the eqation for p() p()= T c= T M I p = b() T p where b() = [b () b () b 2 () b ()] T is an array of blending polynomials sch that p() = b ()p + b ()p + b 2 ()p 2 + b ()p b () = -4.5(-/)(-2/)(-) b () =.5 (-2/)(-) b 2 () = -.5 (-/)(-) b () = 4.5 (-/)(-2/) 4

Blending Fnctions These fnctions are not monotonic Hence the interpolation polynomial will wiggle 5

Other Types of Crves and Srfaces How can we get arond the limitations of the interpolating form Lack of smoothness Discontinos derivatives at join points We have for conditions (for cbics) that we can apply to each segment Use them other than for interpolation Need only come close to the data 6

Hermite Form p () p () p() p() Use two interpolating conditions and two derivative (tangent) conditions per segment Ensres continity and first derivative continity between segments 7

Eqations Interpolating conditions are the same at ends p() = p = c p() = p = c +c +c 2 +c Differentiating we find p () = c +2c 2 + 2 c Evalating at end points p () = p = c p () = p = c +2c 2 +c 8

9 Matrix Form c q " # % & = " # % & = 2 p' p' p p Solving, we find c=m H q where M H is the Hermite matrix " # % & ' ' ' ' = 2 2 2 MH

4 Blending Polynomials p() = b() T q " # % & ' + ' + ' + ' = 2 2 2 2 2 2 2 ) b( Althogh these fnctions are smooth, the Hermite form is not sed directly in Compter Graphics and CAD becase we sally have control points bt not derivatives However, the Hermite form is the basis of the Bezier form

Parametric and Geometric Continity We can reqire the derivatives of x, y,and z to each be continos at join points (parametric continity) Alternately, we can only reqire that the tangents of the reslting crve be continos (geometry continity) The latter gives more flexibility as we have need satisfy only two conditions rather than three at each join point 4

Example Here the p and q have the same tangents at the ends of the segment bt different derivatives Generate different Hermite crves This techniqes is sed in drawing applications 42

Bezier and Spline Crves

Objectives Introdce the Bezier crves Derive the reqired matrices Introdce the B-spline and compare it to the standard cbic Bezier 44

Bezier s Idea In graphics and CAD, we do not sally have derivative data Bezier sggested sing the same 4 data points as with the cbic interpolating crve to approximate the derivatives in the Hermite form 45

Approximating Derivatives p located at =/ p p 2 p 2 located at =2/ p p p # p '() " p'() " 2 / / p slope p () slope p () p p 46

Eqations Interpolating conditions are the same p() = p = c p() = p = c +c +c 2 +c Approximating derivative conditions p () = (p - p ) = c p () = (p - p 2 ) = c +2c 2 +c Solve for linear eqations for c=m B p 47

48 Bezier Matrix " # % & ' ' ' ' = 6 MB p() = T M B p = b() T p blending fnctions

Blending Fnctions b( ) = & ( ' ) # 2 ( ' ) 2 2 ( ' ) % " Note that all zeros are at and which forces the fnctions to be smooth over (,) 49

Bernstein Polynomials The blending fnctions are a special case of the Bernstein polynomials b kd ( ) = d k( d k) ( ) d k These polynomials give the blending polynomials for any degree Bezier form All zeros at and For any degree they all sm to They are all between and inside (,) k 5

Convex Hll Property The properties of the Bernstein polynomials ensre that all Bezier crves lie in the convex hll of their control points Hence, even thogh we do not interpolate all the data, we cannot be too far away Bezier crve p p 2 convex hll p p 5

Analysis Althogh the Bezier form is mch better than the interpolating form, we have the derivatives are not continos at join points Can we do better? Go to higher order Bezier More work Derivative continity still only approximate Spported by OpenGL Apply different conditions Tricky withot letting order increase 52

B-Splines Basis splines: se the data at p=[p i-2 p i- p i p i- ] T to define crve only between p i- and p i Allows s to apply more continity conditions to each segment For cbics, we can have continity of fnction, first and second derivatives at join points Cost is times as mch work for crves Add one new point each time rather than three For srfaces, we do 9 times as mch work 5

54 Cbic B-spline " # % & ' ' ' ' = 6 4 MS p() = T M S p = b() T p

55 Blending Fnctions " # % & ' + + + ' ' = 2 2 2 6 4 ) ( 6 ) b( convex hll property

Splines and Basis If we examine the cbic B-spline from the perspective of each control (data) point, each interior point contribtes (throgh the blending fnctions) to for segments We can rewrite p() in terms of the data points as p( ) = Bi ( ) defining the basis fnctions {B i ()} p i 56

57 Basis Fnctions 2 2 2 2 ) ( ) ( ) ( 2) ( ) ( 2 + + < " + + < " < " # # < " # # < % & ' # + + = i i i i i i i i i i b b b b Bi In terms of the blending polynomials

Generalizing Splines We can extend to splines of any degree Data and conditions to not have to given at eqally spaced vales (the knots) Nonniform and niform splines Can have repeated knots Can force spline to interpolate points Cox-deBoor recrsion gives method of evalation 58

NURBS Nonniform Rational B-Spline crves and srfaces add a forth variable w to x,y,z Can interpret it as weight to give more importance to some control data Can also interpret as moving to homogeneos coordinate Reqires a perspective division NURBS act correctly for perspective viewing Qadrics are a special case of NURBS 59

Every Crve is a Bezier Crve We can render a given polynomial sing the recrsive method if we find control points for its representation as a Bezier crve Sppose that p() is given as an interpolating crve with control points q p()= T M I q There exist Bezier control points p sch that p()= T M B p Eqating and solving, we find p=m B - M I 6

6 Matrices Interpolating to Bezier B-Spline to Bezier " # % & ' ' ' ' = ' 6 5 2 2 6 5 M M I B " # % & = ' 4 4 2 2 4 4 M M S B

Example These three crves were all generated from the same original data sing Bezier recrsion by converting all control point data to Bezier control points Bezier Interpolating B Spline 62

Drawing Bezier Crves in OpenGL

Basic Procedre Enable an evalator (glenable) For vertices, normals and colors Define Bezier parameters (glmapf) Evalate Bezier crve (glevalcoordf, or glmapgridf and glevalmesh) 64

Example GLfloat data[4][]; glenable(gl_map_vertex); glmapf(gl_map_vertex,.,.,, 4, data); glbegin(gl_line_strip); for (i = ; i <= 2; i++) glevalcoordlf(i / 2.); glend(); 65

D Evalator: glmapf() glmap{fd}(glenm entity, TYPE, TYPE, GLint stride, GLint order, TYPE* data); entity describes type entity GL_MAP_VERTEX_, GL_MAP_VERTEX_4, GL_MAP_COLOR_4, GL_MAP_NORMAL and is parameter range stride is nmber of variables between data points order of Bernstein polynomial ( more than degree) 66

Polynomial Order Has a Limit Each OpenGl implementation has a maximm Bernstein polynomial order glgetintergerv(gl_max_eval_order, &max_order); Gets maximm polynomial order e.g. 8,, 5, 67

Defining partitions: glmapgridf() glmapgridf(glint n, TYPE, TYPE ); Defines n eqally spaced partitions between parameters and Prodces n+ samples 68

Evalate Bezier at samples: glevalmesh() glevalmesh(glenm mode, GLint first, GLint last); Renders in mode (GL_LINE, GL_POINT) all enabled evalators from the first to last vales of defined by glmapgrid() 69

Example GLfloat data[4][]; glenable(gl_map_vertex); glmapf(gl_map_vertex,,,, 4, data); glmapgridf(2,, ); glevalmesh(gl_line,, 2); 7

Go to bezier.c