PH36010 Numerical Methods Advanced Plotting and Animation
Advanced Plotting in MathCAD Polar PlotsPolar Plots 3D Plots3D Plots –Surface –Contour –Scatter –Bar Vector Field PlotsVector Field Plots
Polar Plots #1 X-Y Plot wrapped around a circleX-Y Plot wrapped around a circle r=cos 2 ( )
Polar Plots #2 r=e k r=e k
Uses for Polar Plots Rotating MachinesRotating Machines –Stirling engine –Vibration Arctic & Antarctic systemsArctic & Antarctic systems
3D surface plots Simple #1 Plot of data stored in arrayPlot of data stored in array Indices of array represent x-y planeIndices of array represent x-y plane Value of matrix is z valueValue of matrix is z value –Define size of matrix & indices –Determine values for x & y –Fill matrix –Plot
3D surface plots Simple #2 Define size & indicesDefine size & indices Define Range for x & yDefine Range for x & y 2D-Gaussian2D-Gaussian Fill matrixFill matrix
3D surface plots Simple #3
3D surface plots Simple #4 – Lighting
Contour Plot - from 3d plot data Format plot type -> Contour plotFormat plot type -> Contour plot
Simple 3D plots Limitations X & Y axes scaled in indicesX & Y axes scaled in indices Suited to continuous single valued functionsSuited to continuous single valued functions More advanced 3D plots availableMore advanced 3D plots available
3D Scatter plot Plot of individual pointsPlot of individual points Supply with 3 vectors of equal length (X,Y,Z)Supply with 3 vectors of equal length (X,Y,Z) Points plotted:Points plotted: –X 0,Y 0,Z 0 –X 1,Y 1,Z 1 –…–…–…–…
3D scatter plot Photon Scatter in 3D
3D surface plots Parametric Plot Plot complex surfacesPlot complex surfaces From Resource Centre Guide to 3D plottingFrom Resource Centre Guide to 3D plotting
3D parametric plot Example - for H X- & Y- Axes scaled in m
Parametric Plots How to… #1 Rubber sheet N x MRubber sheet N x M Wrap sheet around surfaceWrap sheet around surface XX a,b is x-coord of point a,bXX a,b is x-coord of point a,b YY a,b is y-coord of point a,bYY a,b is y-coord of point a,b ZZ a,b is z-coord of point a,bZZ a,b is z-coord of point a,b (XX,YY,ZZ) will plot surface(XX,YY,ZZ) will plot surface
Parametric Plots Example 1 - Gaussian Ranges defined as beforeRanges defined as before Fill XX & YY matricesFill XX & YY matrices Fill ZZ matrixFill ZZ matrix
Parametric Plots Example 1 - Gaussian Note:Note: –Axes scaled
A short diversion Simple Program #1 Often need to create a vector containing a range of valuesOften need to create a vector containing a range of values Create function to do this using MathCAD program stepsCreate function to do this using MathCAD program steps Use in graphics programsUse in graphics programs
The SeriesVector() program (increment) and i (loop count) are ‘local’ to function. Function builds Result vector Returned on last line of program
Testing the SeriesVector() function
Parametric Plots Polar 3D #1 Create r vector 0-10 radii, 100 tepsCreate r vector 0-10 radii, 100 teps Create vector deg, 30 stepsCreate vector deg, 30 steps Fill X & Y vectorsFill X & Y vectors
Paramteric Plots Polar 3D #2 Define 100 function Fill Z matrix with 100 function 100 function NB Only depends on r
3D parametric plot Example - for H X- & Y- Axes scaled in m
Plot of for H X & Y matrices as beforeX & Y matrices as before Z now depends on r,qZ now depends on r,q
3D parametric plot Example - for H
Vector Field Plots #1 Arrows give strength & direction of field at each point of plot.Arrows give strength & direction of field at each point of plot. Constructed from either:Constructed from either: –Matrix of complex numbers –2 identical matrices of real numbers
Vector Field Plots #2 From Resource Centre Example function to plotExample function to plot Gradient function of f(x,y)Gradient function of f(x,y)
Vector Field Plot Surface Plot Vector Field Plot
Pretty Pictures #1 From Resource Centre Chain of Tori Pyramid
Pretty Pictures From Resource Centre Plot multiple Surfaces
Pretty Pictures #3 Planetary Orbit 3 objects3 objects –Planet : (xe,ye,ze) –Star : (xs,ys,zs) –Orbit: (xp,yp,zp)
Animation Principles Make output depend on FRAMEMake output depend on FRAME Tools|Animation|Record… to display dialogTools|Animation|Record… to display dialog –Fill in first & last frames –Drag cursor around area to animate –Select ‘Animate’ to go –View with AVI player –Save to disk Help|Quicksheets|Graphing and VisualizationHelp|Quicksheets|Graphing and Visualization
Animation Hints and Tips Fix scale of graphsFix scale of graphs Watch out for:Watch out for: –Size of AVI files –Long calculation times Can test by using FRAME:=Can test by using FRAME:= –Delete afterwards Put indicator in moviePut indicator in movie
Animation Example #1 Cannon Ball with drag
Animation Example #2 LCR at resonance
Animation Example #3 Heat Flow in Plate
Animation Example #4 Planetary Orbits
3D with lighting & shadows
Ideas for projects Bouncing ballsBouncing balls –Gravity –Snooker Electron clouds around HElectron clouds around H Simulation of Ion ImplantationSimulation of Ion Implantation Heat flow by finite differenceHeat flow by finite difference