 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Sorce: Suggestive Contours for Conveying Shape. (SIGGRAPH 2003) Doug DeCarlo, Adam Finkelstein, Szymon Rusinkiewicz, Anthony Santella. 1 Suggestive Contours.
Chapter 11 Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.
©1999 BG Mobasseri 15/24/99 INTERPOLATION AND CURVE FITTING Etter: pp June 16, ‘99.
Introduction to Matlab:
Coordinates and Design.  What numbers would you write on this line?  Each space is 1 unit 0.
Fall 2006AE6382 Design Computing1 Three Dimensional Plotting Learning Objectives –Understand the anatomy of a 3D plot –Basics of constructing plots in.
Texture Mapping from Watt, Ch. 8 Jonathan Han. Topics Discussed Texture Map to Models Bump Maps, Light Maps Environment (Reflection) Mapping 3D Textures.
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
EPSII 59:006 Spring Outline Managing Your Session File Usage  Saving Workspace  Loading Data Files  Creating M-files More on Matrices Review.
©1999 BG Mobasseri18/25/2015 June 21, ‘99. ©1999 BG Mobasseri28/25/2015 EVALUATING DEFINITE INTEGRALS  MATLAB can evaluate definite integrals like 
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
COMP 175: Computer Graphics March 24, 2015
Copyright - Planchard 2012 History of Engineering Graphics Stephen H. Simmons TDR 200.
Matlab Training Sessions 6,7: Plotting. Course Outline Weeks: 1.Introduction to Matlab and its Interface (Jan ) 2.Fundamentals (Operators) 3.Fundamentals.
CMPS 1371 Introduction to Computing for Engineers PLOTTING.
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
Plotting – 3-Dimensional. 3D Plots versus 2D Plots 3-dimensional plots, in contrast to 2-dimensional ones, has a third axis (often called the z-axis).
MATLAB Plotting With MATLAB 1. Two Dimensional Plots The xy plot is the most commonly used plot by engineers The independent variable is usually called.
Coordinates and Design
Section 17.5 Parameterized Surfaces
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
The Hong Kong Polytechnic University Industrial Centre 1 MatLAB Lesson 4 : Polynomial Edward Cheung Room W311g 2008.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers Chapter 5B Model.
Vectors and the Geometry of Space 2015
Graphics Lecture 13: Slide 1 Interactive Computer Graphics Lecture 13: Radiosity - Principles.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
CS559: Computer Graphics Lecture 8: Warping, Morphing, 3D Transformation Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
2D Routines in 3D. Outline Announcements –HW II--due Friday. 5PM HW1 & Cookie Grids & Meshes Representing f(x,y) Lines & Surfaces in 3D Survey.
ConcepTest Section 12.2 Question 1 Let be the distance above the ground (in feet) of a jump rope x feet from one end after t seconds. The two people turning.
Copyright © Cengage Learning. All rights reserved. 16 Vector Calculus.
Numerical Analysis 3D Plots. A numerical method is a technique for computing a numerical approximation of the solution to a mathematical problem.
Recap Plots with More than one Line Plots of Complex Arrays Line, Color and Mark Style Axis Scaling and Annotating Plots Subplots Polar Plots Logarithmic.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
ELG 3120 Lab 2 TAs Wei Zhang Ozgur Ekici (Section A) (Section B)
June 14, ‘99 COLORS IN MATLAB.
October 16, 2014Computer Vision Lecture 12: Image Segmentation II 1 Hough Transform The Hough transform is a very general technique for feature detection.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 2 Friday 07 Nov 2014 EGR 115 Introduction to Computing for Engineers.
Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 10: 3D & Projections Advanced.
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Deniz Savas & Mike Griffiths May 2015.
MOHR'S CIRCLE The formulas developed in the preceding article may be used for any case of plane stress. A visual interpretation of them, devised by the.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
Functions Objective: To determine whether relations are functions.
More Matlab Graphics and GUI Graphics subplots some useful commands 3D graphics GUI GUI controls The callback property Other essential properties.
EEE 242 Computer Tools for Electrical Engineering
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Lecture 17 More Plotting Chapter 12 Matrices. Outline from Chapter D Plotting 11.4 Surface Plots 11.5 Interacting with Plotted Data.
Session III Plotting in MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU MATLAB Tutorials.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Computer Graphics Lecture 07 Ellipse and Other Curves Taqdees A. Siddiqi
CS112 Scientific Computation Department of Computer Science Wellesley College Kodak moments 3-D Visualization and Color.
CS112 Scientific Computation Department of Computer Science Wellesley College Kodak moments 3-D Visualization and Color.
Introduction to Functions of Several Variables
ENEE222 Elements of Discrete Signal Analysis Lab 11 1.
3D-Graphs A 3D surface is defined as: z = f(x, y)
Ch3 Graphics Overview of Plotting Editing Plots
2D Routines in 3D.
Introduction to MATLAB Plotting LAB 3
CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Yang-Ming University, Taipei, Taiwan
15.7 Triple Integrals.
Presentation transcript:

 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99

 1999 BG Mobasseri2 8/29/ D PLOTTING There are numerous ways to display a function in 3-D in black and white as well as color One way to interpret 3D data is a series of points in space given by (x,y,z) coordinates The direct extension of the 2-D plot function, plot(x,y), to 3-D is plot3(x,y,z)

 1999 BG Mobasseri3 8/29/2015 PLOTTING A CORKSCREW How would you model a corkscrew? Corkscrew, or spiral, is the 3-D equivalent of a spiral It goes around a circle but it also rises from the ground plane. So, what is its equation?

 1999 BG Mobasseri4 8/29/ D EQUATION A circle can be parametrically described by –x=cos(t) –y=sin(t) To make it rise from the ground plane, let z=t and run t from 0 to 10*pi.

 1999 BG Mobasseri5 8/29/2015 Try it!

 1999 BG Mobasseri6 8/29/2015 Try it! Another interesting plot is the same as corkscrew but you are going up around a cone rather than a cylinder. Can you write the code?

 1999 BG Mobasseri7 8/29/2015 DISPLAYING A FUNCTION AS A SET OF HEIGHTS A 3-D plot can be interpreted as heights above the ground plane. These heights are evaluated at some predefined grid points

 1999 BG Mobasseri8 8/29/2015 mesh and meshgrid To plot a function in 3D we need to understand mesh and meshgrid. meshgrid samples the ground plane into a grid of points –x=- 8:0.5:8; –y=x; –[x,y]=meshgrid(x,y) x and y are now matrices mesh evaluates the function over the grid

 1999 BG Mobasseri9 8/29/2015 EXMAPLE: SOMBRERO Sombrero, looking like a Mexican hat, is defined by sin(r)/r. r is the distance of a point (x,y) to the origin, i.e. –r 2 =x 2 +y 2 r

 1999 BG Mobasseri10 8/29/2015 Try it!

 1999 BG Mobasseri11 8/29/2015 SOMBRERO

 1999 BG Mobasseri12 8/29/2015 GENERATING TRUE AXIS UNITS Use of mesh (z) plots z vs. index positions not actual x or y values To plot z vs. actual units of x and y, just use x and y in the mesh command like –mesh(x,y,z) Note that x and y can come from the output of meshgrid

 1999 BG Mobasseri13 8/29/2015 Try it! MATLAB has a built-in function called peaks How can you make the plot look smoother?

 1999 BG Mobasseri14 8/29/2015 What to do in the following slides Each slide shows a variation of the mesh command on a function z Since you already have z defined for both sombrero and peaks, for each slide duplicate the command shown and see the result for yourself

 1999 BG Mobasseri15 8/29/2015 CONTOUR PLOT Contours are slices of constant height that are then projected onto the ground plane In its simplest form meshc (z) does the job

 1999 BG Mobasseri16 8/29/2015 CURTAIN PLOT You can put your plot on a ‘pedestal’ by using meshz (Z)

 1999 BG Mobasseri17 8/29/2015 CONTROLLING VIEWPOINT Viewpoint is controlled by two angles: azimuth and elevation Azimuth is rotation around the Z-axis Elevation is rising above the ground plane z x y el az

 1999 BG Mobasseri18 8/29/2015 DEFAULT VIEWPOINTS In MATLAB, default viewpoints are az= and el=30 degrees Zero degrees azimuth is like looking up the x- axis shown in the previous slide. 90 degrees of elevation is like looking directly down on the the surface

 1999 BG Mobasseri19 8/29/2015 Working with viewpoint The best way to understand viewpoint is to play around To understand the effect of elevation, fix your azimuth at 0 then change your elevation: –view(0,10),view(0,30),view(0,60) Or fix your elevation at 30 degrees and change your azimuth –Compare view(30,60) with view(-20, 60)

 1999 BG Mobasseri20 8/29/2015 INTERPRETING SIGNS OF VIEWPOINT ANGLES Increasingly negative azimuth angle corresponds to holding the object in front of you and rotating it counterclockwise. Equivalently, it corresponds to keeping the object stationary and moving around it clockwise Positive elevation angle mean rising above the object. Elevation of +90 degrees means being directly overhead and looking down

 1999 BG Mobasseri21 8/29/2015 Homework#1 For the following function –do a mesh plot then title and label all axis –visually find out how deep the hole is? –what is happening inside(looking underneath)? –generate 3D contours(30 of them) –Write a procedure that would cap the plot to 70% of its peak value then plot it. Your plot should show a flat top

 1999 BG Mobasseri22 8/29/2015 GENERATING SHADED PLOTS mesh generates wiremesh plots(can see lines) To generate surfaces with solid shading, surf and its variations are used These variations are –surf –surfl (this is surf followed by lower case L) –surfc

 1999 BG Mobasseri23 8/29/2015 Using surf Usage: –surf(x,y,z,C) (x,y) is generated via meshgrid and z is the height of the function. z-to-color mapping is done according to the entries into “colormap” via C. More on this later If surf(z) is used, color is proportional to height z.

 1999 BG Mobasseri24 8/29/2015 Plotting peaks using surf Generate the peaks function in the range (-4 to 4) in increments of.5 Then use –surf(x,y,z) For comparison, use mesh and display it in a second window

 1999 BG Mobasseri25 8/29/2015 Try it! Look closely and see if you can tell the difference between surf and mesh

 1999 BG Mobasseri26 8/29/2015 mesh vs. surf Display mesh and surf side-by-side

 1999 BG Mobasseri27 8/29/2015 SOLID SHADING- shading To plot solid looking shapes, as opposed to wiremeshes, shading command comes in –shading flat –shading faceted –shading interp

 1999 BG Mobasseri28 8/29/2015 Try it! Display one of your favorite 3D shapes you have done so far and in the command window type and observe –shading flat –shading faceted –shading interp

 1999 BG Mobasseri29 8/29/2015 FLAT vs. FACETED vs. INTERPOLATED SHADING Flat shading assigns constant colors to surface patches Faceted shading assigns constant colors but also shows the wiremeshes Interpolated shading assigns colors proportional to height of the function

 1999 BG Mobasseri30 8/29/2015 3D CONTOURS contour projects 3D contours of a surface onto the ground plane contour3 shows the true 3D contours Usages are –contour3(x,y,z,N) This command generates N contours of the function Z. Default is N=10

 1999 BG Mobasseri31 8/29/2015 Try it! Display the peaks function over x and y ranging over - 5 to 5 in increments of 0.1 Then do the following –Display 50 2D contours using contour –Display 50 3D contours using contour3d

 1999 BG Mobasseri32 8/29/2015 FEW EXAMPLES 20 contours

 1999 BG Mobasseri33 8/29/2015 Can you get this? Hint: contour displays its plots on the z=0 plane

 1999 BG Mobasseri34 8/29/2015 CONTROLLING LIGHTING DIRECTION-surfl You can shine light on a surface from a desired direction Shading is based on a combination of diffuse, specular and ambient lighting models Usage: –surfl(x,y,z,s) –s=lighting direction=[az,el] where az and el are azimuth and elevation angles previously defined

 1999 BG Mobasseri35 8/29/2015 Lighting example Keep changing the s parameter and watch

 1999 BG Mobasseri36 8/29/2015 WATERFALL PLOTS An interesting effect can be generated by just plotting the rows of the Z matrix using –waterfall(x,y,z)

 1999 BG Mobasseri37 8/29/2015 Putting several plots on a single page subplot(mnp) divides the page into m(rows)xn(columns) tiles then selects the pth tile for the current plot This tile would be Referred to by subplot (235)

 1999 BG Mobasseri38 8/29/2015 Seeing subplot at work Let’s say we want to partition the page into 3x2=6 tiles. Simply type the following in the command window and see what happens –subplot(232) –subplot(235) –subplot(233) –subplot(234) –subplot(236)

 1999 BG Mobasseri39 8/29/2015 Homework #2: placing 4 plots on a page Let’s say we have 4 plots (choose your own) and want to arrange them on paper in the following styles –Across the page in one row –Vertical in one column –In a matrix, 2x2 tiles on a page

 1999 BG Mobasseri40 8/29/2015 Special surfaces: cylinder and sphere sphere(n) will generate a plot of unit sphere using (n+1)^2 points. Another usage is –[x,y,z]=sphere(25); –surf(x,y,z) Similarly, we can generate a cylinder of radius 1 using cylinder.

 1999 BG Mobasseri41 8/29/2015 Generalized cylinder Think of a cylinder with changing cross section

 1999 BG Mobasseri42 8/29/2015 How to do it? Usage: –Cylinder(radius) where radius is the growing cross sectional radius described by a vector

 1999 BG Mobasseri43 8/29/2015 Homework #3 Plot z=sin(sqrt(x^2+y^2)). Plot it using –mesh –surf, surfl, surfc –Experiment with shading: flat, faceted, interpolated –Experiment with lighting directions. For good effect type colormap(copper) after bringing up the plot.