Download presentation
Presentation is loading. Please wait.
Published byEdwina Simon Modified over 9 years ago
1
Computational Biology, Part E Basic Principles of Computer Graphics Robert F. Murphy Copyright 1996, 1999, 2000, 2001. All rights reserved.
2
2D Coordinate Systems Basic 2D Graphics Goal: Display an object or a set of objects which are defined in some coordinate system specified by the user using the coordinate system of a graphics device Basic 2D Graphics Goal: Display an object or a set of objects which are defined in some coordinate system specified by the user using the coordinate system of a graphics device user coordinates may or may not correspond to “real world” coordinates geographical map - yes stock prices vs. time - no
3
2D Coordinate Model World Coordinate Plane Device Coordinate Plane
4
“World” or “User” Coordinates Units may be anything and may be different for x and y Units may be anything and may be different for x and y Three equivalent methods to describe the coordinates of an object Three equivalent methods to describe the coordinates of an object Absolute x,y values (“absolute” coordinates) Relative to object origin (“local” coordinates) Relative to previous position (“relative” coordinates)
5
“World” or “User” Coordinates 3,1 4,2 5,1 Absolute * 1,1 1,-1 Relative * 1,1 2,0 Local * 1st coordinates must be absolute
6
“Physical” or “Device” Coordinates Different for each device Different for each device Units are some measure of actual distance (such as pixels, inches, etc.) and are normally the same for x and y Units are some measure of actual distance (such as pixels, inches, etc.) and are normally the same for x and y
7
Windows and Viewports Output devices such as monitors have finite sizes, so we cannot visualize entire plane Output devices such as monitors have finite sizes, so we cannot visualize entire plane We define a viewport as a rectangular portion of the World we wish to see We may also wish to use only a portion of our output device to display a graph We may also wish to use only a portion of our output device to display a graph We define a window as a rectangular portion of the Device we wish to use
8
Windows and Viewports World Coordinate Plane Device Coordinate Plane Viewport Window
9
Windows and Viewports Note that many differents terminologies are used for these concepts and that window and viewport as used here are reversed from the way they are used in many computer graphics texts Note that many differents terminologies are used for these concepts and that window and viewport as used here are reversed from the way they are used in many computer graphics texts
10
Windows and Viewports 4 values (x & y coordinates of two points) required to specify viewport 4 values (x & y coordinates of two points) required to specify viewport e.g., positions of lower left and upper right corners 4 values (x & y coordinates of two points) required to specify window 4 values (x & y coordinates of two points) required to specify window These 8 values define a unique transformation from World to Device coordinates These 8 values define a unique transformation from World to Device coordinates
11
The Basic Linear Transformation We can convert from World (unprimed) to Device (primed) coordinates using the following equations: We can convert from World (unprimed) to Device (primed) coordinates using the following equations:
12
The Basic Linear Transformation We can convert these equations to the form We can convert these equations to the form These equations simultaneously scale and translocate These equations simultaneously scale and translocate
13
The Basic Linear Transformation (Demonstration C1, Part 1) (Demonstration C1, Part 1)
14
Transformation matrices Can use matrix notation to simplify description of calculations Can use matrix notation to simplify description of calculations Goal: Be able to use a single transformation matrix to convert fromWorld to Device coordinates Goal: Be able to use a single transformation matrix to convert fromWorld to Device coordinates Problem: Scaling requires multiplication, translocation requires addition Problem: Scaling requires multiplication, translocation requires addition Solution: Use homogeneous coordinates Solution: Use homogeneous coordinates
15
Transformation matrices Homogeneous coordinates: Add an extra coordinate to both World and Device coordinates Homogeneous coordinates: Add an extra coordinate to both World and Device coordinates Translation, scaling and rotation can now be done with a single matrix (set w=1) Translation, scaling and rotation can now be done with a single matrix (set w=1)
16
Transformation Matrices Translation (Displacement) Translation (Displacement)
17
Transformation Matrices Scaling Scaling
18
Transformation Matrices Rotation about x axis Rotation about x axis
19
Transformation Matrices Rotation about origin Rotation about origin
20
Transformation matrices Net transformation can be obtained by multiplying matrices Net transformation can be obtained by multiplying matrices Transformation matrices can be implemented in display hardware for dramatic speed improvement Transformation matrices can be implemented in display hardware for dramatic speed improvement When not implemented in hardware, tradeoff increased cost for matrix computation vs. ease in manipulation When not implemented in hardware, tradeoff increased cost for matrix computation vs. ease in manipulation
21
Transformation Matrices (Demonstration C1, Part 2) (Demonstration C1, Part 2)
22
Non-linear transformations Transformations such as logarithms can be implemented using run-time computation or precomputed lookup tables Transformations such as logarithms can be implemented using run-time computation or precomputed lookup tables
23
Graphing Data in Excel Since all graphs on our monitor are two- dimensional, how can we graph data for a single variable (where does the other dimension come from)? Since all graphs on our monitor are two- dimensional, how can we graph data for a single variable (where does the other dimension come from)? When only one variable is available, Excel “creates” a variable called the category. It then plots the original variable versus the category. By default, the category consists of the numbers starting from 1 and incrementing by 1.
24
Graphing Data in Excel Types of graphs that require only one row or column of data (categorical graphs) Types of graphs that require only one row or column of data (categorical graphs) Area, Line, 3D Area, 3D Line Bar, Column, 3D Bar, 3D Column Pie, Doughnut, Radar, 3D Pie (3rd dimension for the 3D plots has depth of 1) If more than one row or column of data is provided, additional lines, bars, etc. are created If more than one row or column of data is provided, additional lines, bars, etc. are created
25
Graphing Data in Excel Types of graphs requiring two or more rows or columns of data (correlated or XYgraphs) Types of graphs requiring two or more rows or columns of data (correlated or XYgraphs) XY (scatter) If XY graph is selected but only one row or column of data are present, categorical values are generated and plot becomes equivalent to a Line graph 3D surface
26
Graphing Data in Excel (Demonstration C2) (Demonstration C2)
27
Graphing Data in Excel Graphing Tip: When values to be plotted are not present in conveniently adjacent cells, data can be “collected” using references to cells containing original data Graphing Tip: When values to be plotted are not present in conveniently adjacent cells, data can be “collected” using references to cells containing original data
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.