CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.

Slides:



Advertisements
Similar presentations
Computer Graphics 2D & 3D Transformation.
Advertisements

College of Computer and Information Science, Northeastern UniversityApril 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007 Lecture.
Computer Graphics (Spring 2008) COMS 4160, Lecture 6: Curves 1
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
CLASS 4 CS770/870. Translation Scale Multiplying Matrices. The R C rule What happens when we do two translates? What happens when we do two scales?
© University of Wisconsin, CS559 Spring 2004
Lecture 10 Curves and Surfaces I
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
Slide 127 October 1999CS Computer Graphics (Top Changwatchai) Review of Spline Concepts Sections 10-6 to in Hearn & Baker Splines can be 2D.
Splines II – Interpolating Curves
Hierarchical Modeling I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 Dr. Scott Schaefer Curves and Interpolation. 2/61 Smooth Curves How do we create smooth curves?
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
Hierarchical Modeling II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Transformations III Week.
2IV60 Computer Graphics 2D transformations
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
Hierarchy, Modeling, and Scene Graphs Angel: Chapter 10 OpenGL Programming and Reference Guides, other sources. ppt from Angel, AW, etc. CSCI 6360/4360.
COMP 175: Computer Graphics March 10, 2015
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
CS 376 Introduction to Computer Graphics 04 / 23 / 2007 Instructor: Michael Eckmann.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Week 4 Lecture 1: Hierarchical Modeling Part 1 Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E ©
Hierarchical Modeling. Instance Transformation Start with a prototype object (a symbol) Each appearance of the object in the model is an instance – Must.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 40 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 40 Computer Graphics Hierarchy I.
CS559: Computer Graphics Lecture 15: Hierarchical Modeling and Shading Li Zhang Spring 2008.
June D Object Representation Shmuel Wimer Bar Ilan Univ., School of Engineering.
Curves and Surfaces Chapter 10. CS 480/680 2Chapter 9 -- Hierarchical Models Introduction: Introduction: Until now we have worked with flat entities such.
111/16/ :14 UML Instance Transformation x y z x y z x y z x y z SRT Model Coordinates.
CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008.
1 Hierarchical and Object-Oriented Graphics Construct complex models from a set of simple geometric objects Extend the use of transformations to include.
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
Transformations Tutorial
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
Basic Theory (for curve 02). 1.3 Parametric Curves  The main aim of computer graphics is to display an arbitrary surface so that it looks real.  The.
Computer Graphics I, Fall 2008 Hierarchical Modeling II.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
Designing Parametric Cubic Curves 1. 2 Objectives Introduce types of curves ­Interpolating ­Hermite ­Bezier ­B-spline Analyze their performance.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 12: Curves 1
College of Computer and Information Science, Northeastern UniversityFebruary 27, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lectures.
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
CS559: Computer Graphics Lecture 12: OpenGL: ModelView Li Zhang Spring 2010.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
CS552: Computer Graphics Lecture 19: Bezier Curves.
Computer Graphics I, Fall 2008 Hierarchical Modeling I.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
Introduction to Parametric Curve and Surface Modeling.
Lecture 18: FLTK and Curves Li Zhang Spring 2008
CSE 167 [Win 17], Lecture 9: Curves 1 Ravi Ramamoorthi
Computer Graphics - Hierarchical Models-
Hierarchical and Object-Oriented Graphics
© University of Wisconsin, CS559 Fall 2004
CSCE 441: Computer Graphics: Hierarchical Models
© University of Wisconsin, CS559 Spring 2004
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Hierarchical and Object-Oriented Graphics
Transformations in OpenGL
Hierarchical Modeling & Constructive Solid Geometry
Geometric Objects and Transformations (II)
Transformations III Week 3, Mon Jan 21
Introduction to Parametric Curve and Surface Modeling
Hierarchical Modeling
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010

Last time: 3D Example: A robot arm Consider this robot arm with 3 degrees of freedom: – Base rotates about its vertical axis by  – Upper arm rotates in its xy-plane by  – Lower arm rotates in its xy-plane by  h1h1 h2h2 h3h3 Base Upper arm Lower arm z x y y x x Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  )

Robot arm implementation The robot arm can be displayed by keeping a global matrix and computing it at each step: Matrix M_model; display(){... robot_arm();... } robot_arm() { M_model = R_y(theta); base(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi); upper_arm(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi)*T(0,h2,0)*R_z(psi); lower_arm(); } Matrix M_model; display(){... robot_arm();... } robot_arm() { M_model = R_y(theta); base(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi); upper_arm(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi)*T(0,h2,0)*R_z(psi); lower_arm(); } Do the matrix computations seem wasteful? How to translate the whole robot? Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  ) Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  )

Instead of recalculating the global matrix each time, we can just update it in place by concatenating matrices on the right: Robot arm implementation, better Matrix M_model; display(){... M_model = identity; robot_arm();... } robot_arm() { M_model *= R_y(theta); base(); M_model *= T(0,h1,0)*R_z(phi); upper_arm(); M_model *= T(0,h2,0)*R_z(psi); lower_arm(); } Matrix M_model; display(){... M_model = identity; robot_arm();... } robot_arm() { M_model *= R_y(theta); base(); M_model *= T(0,h1,0)*R_z(phi); upper_arm(); M_model *= T(0,h2,0)*R_z(psi); lower_arm(); }

OpenGL maintains the model-view matrix, as a global state variable which is updated by concatenating matrices on the right. display() {... glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); robot_arm();... } robot_arm() { glRotatef( theta, 0.0, 1.0, 0.0 ); base(); glTranslatef( 0.0, h1, 0.0 ); glRotatef( phi, 0.0, 0.0, 1.0 ); lower_arm(); glTranslatef( 0.0, h2, 0.0 ); glRotatef( psi, 0.0, 0.0, 1.0 ); upper_arm(); } display() {... glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); robot_arm();... } robot_arm() { glRotatef( theta, 0.0, 1.0, 0.0 ); base(); glTranslatef( 0.0, h1, 0.0 ); glRotatef( phi, 0.0, 0.0, 1.0 ); lower_arm(); glTranslatef( 0.0, h2, 0.0 ); glRotatef( psi, 0.0, 0.0, 1.0 ); upper_arm(); } Robot arm implementation, OpenGL

Hierarchical modeling Hierarchical models can be composed of instances using trees: – edges contain geometric transformations – nodes contain geometry (and possibly drawing attributes) How might we draw the tree for the car?

A complex example: human figure Q: What’s the most sensible way to traverse this tree?

Human figure implementation, OpenGL figure() { torso(); glPushMatrix(); glTranslate(... ); glRotate(... ); head(); glPopMatrix(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_upper_arm(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_lower_arm(); glPopMatrix();... } figure() { torso(); glPushMatrix(); glTranslate(... ); glRotate(... ); head(); glPopMatrix(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_upper_arm(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_lower_arm(); glPopMatrix();... }

Curves x y line circle x y Freeform x y

Curve Representation x y line circle x y c d t c d t Explicit: Implicit: Parametric:

Curve Representation x y line circle x y c d t c d t Parametric:

Curve Representation x y line circle x y c d t c d t Parametric:

Curve Representation x y line circle x y c d t c d t Parametric: Any invertible function g will result in the same curve

What are Parametric Curves? Define a mapping from parameter space to 2D or 3D points – A function that takes parameter values and gives back 3D points The result is a parametric curve 0 t1 Mapping:F:t→(x,y,z) 0 1 (F x (t), F y (t), F z (t),)

An example of a complex curve Piecing together basic curves

Continuities

Polynomial Pieces Polynomial functions: Polynomial curves:

Polynomial Evaluation Polynomial functions: f = a[0]; for i = 1:n f += a[i]*power(t,i); end f = a[0]; for i = 1:n f += a[i]*power(t,i); end f = a[0]; s = 1; for i = 1:n s *= t; f += a[i]*s; end f = a[0]; s = 1; for i = 1:n s *= t; f += a[i]*s; end f = a[n]; for i = n-1:-1:0 f = a[i]+t*f; end f = a[n]; for i = n-1:-1:0 f = a[i]+t*f; end

A line Segment We have seen the parametric form for a line: Note that x, y and z are each given by an equation that involves: – The parameter t – Some user specified control points, x 0 and x 1 This is an example of a parametric curve p0 p1

A line Segment We have seen the parametric form for a line: p0 p1 From control points p, we can solve coefficients a

More control points p0 p1 p2

More control points p0 p1 p2 By solving a matrix equation that satisfies the constraints, we can get polynomial coefficients

Two views on polynomial curves From control points p, we can compute coefficients a Each point on the curve is a linear blending of the control points

What are b0(t), b1(t), …? Two control point case: b 0 (t) b 1 (t)

What are b0, b1, …? Three control point case: Which is b 0 (t)?

What are b0, b1, …? Why is important? – Translation-invariant interpolation Three control point case: for any t

Many control points p0 p1 p2 pn Straightforward, but not intuitive

Many control points A shortcut Goal: Idea: Magic: Getting b i (t) is easier! Why? is a polynomial of degree n Lagrange Interpolation If an n-degree polynomial has the same value at n+1 locations, it must be a constant polynomial

Lagrange Polynomial Interpolation

Lagrange Interpolation Demo agrange.htm agrange.htm Properties: – The curve passes through all the control points – Very smooth: C n for n control points – Do not have local control – Overshooting

Piecewise Cubic Polynomials Desired Features: – Interpolation – Local control – C1 or C2

Natural Cubics

If we have n points, how to use natural cubic to interpolate them? – Define the first and second derivatives for the starting point of the first segment. – Compute the cubic for the first segment – Copy the first and second derivatives for the end point of the first segment to the starting point for the second segment How many segments do we have for n control points? n-1

Natutral Cubic Curves Demo:

Natural Cubics Interpolate control points Has local controlC2 continuity Natural cubics

Hermit Cubics

Hermite Cubic Curves If we have n points, how to use Hermite cubic to interpolate them? – For each pair, using the first derivatives at starting and ending points to define the inbetween How many segments do we have for n controls? – n/2-1

Hermite Cubies Interpolate control points Has local controlC2 continuity Natural cubicsYesNoYes Hermite cubics