COMP261 Lecture 4 Graphs 3 of 3.

Slides:



Advertisements
Similar presentations
GEOMETRIC REPRESENTATION OF COMPLEX NUMBERS A Complex Number is in the form: z = a+bi We can graph complex numbers on the axis shown below: Real axis.
Advertisements

Trigonometric Form of Complex Numbers
Activity Set 3.2 PREP PPTX Visual Algebra for Teachers.
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
CS 4731: Computer Graphics Lecture 4: 2D Graphic Systems
Introduction Many relationships can be represented by linear equations. Linear equations in two variables can be written in the form y = mx + b, where.
EXAMPLE 2 Graphing Points in a Coordinate Plane SOLUTION Begin at the origin, move 4 units to the right, then 2 units down. Point A lies in Quadrant IV.
Geometry: Dilations. We have already discussed translations, reflections and rotations. Each of these transformations is an isometry, which means.
Dilations.
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
IGCSE Revision Lesson 3 I can calculate the gradient of a straight line from the co-ordinates of two points on it I can calculate the length and the co-ordinates.
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
Windowing and clipping
Events and Coordinates Lecture 5 Fri, Sep 5, 2003.
Graphing Linear Equations. click on the topic to go to that section Table of Contents Vocabulary Review Defining Slope on the Coordinate Plane Tables.
Section 2.2 Lines. OBJECTIVE 1 Find the slope of the line containing the points (–1, 4) and (2, –3).
COMP261 Lecture 3 Graphs 2 of 3. Locations (The Hardest Part of A1?) Three representations of a location/place/point latitude/longitude –what you need.
1 General Camera ©Anthony Steed Overview n Simple camera is limiting and it is necessary to model a camera that can be moved n We will define.
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
Computer Graphics Camera Projection / Picking CO2409 Week 8 - Optional Advanced Material Not on Exam.
Histograms Lecture 14 Sec Fri, Feb 8, 2008.
Algebra 2 Fall Semester Exam Review Test Format Final Exam is all calculator 35 Questions All Multiple Choice.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
11.2a Geometric Representation of a Complex Number Write complex numbers in polar form.
Geometry Lesson 8 – 2 Extended Coordinates in Space Objective: Use ordered triple with distance and midpoint formulas.
Geometry Rotations. 2/14/2016 Goals Identify rotations in the plane. Apply rotation formulas to figures on the coordinate plane.
Mapdraw ats315. Today’s goal: Drawing a map in the graphics window! Drawing a map in the graphics window!
Project 2 Function Plotter Mon, Sep 22, 2003 Due Mon, Sep 29, 2003.
Equations of Circles. You can write an equation of a circle in a coordinate plane, if you know: Its radius The coordinates of its center.
12-2 Translations Holt Geometry I CAN I CAN - Translate figures on the coordinate plane - Translate figures on the coordinate plane -Can convert between.
3/15/ : The Distance Formula 5.6: The Distance Formula and the Method of Quadrature Expectation: G1.1.5: Given a line segment in terms of its endpoints.
Texture Mapping What is texture mapping? - a method for adding detail, surface texture (a bitmap or raster image), or color to a computer-generated graphic.
Draw a line through the points A(1,-2) and D(4,4). Find the coordinates of 2 more points on the line.
From AutoCAD to ArcView. From AutoCAD to Arcview Purpose Display a site plan drawn in AutoCad on a view drawn in ArcView Given Campus site plan drawing.
Slope of a Line Unit 7 Review of Slope and Graphing Linear Equations.
Line Drawing Algorithms 1. A line in Computer graphics is a portion of straight line that extends indefinitely in opposite direction. 2. It is defined.
A structured walkthrough
Geometry Rotations.
Geometry 4-3 Rotations.
COMP 261 Lecture 2 Graphs 1 of 3.
Chapter 1: Linear Functions, Equations, and Inequalities
Translations and Reflections
World Coordinate System: You Choose!
Learning Objectives • Dynamic Input Line tool. • Coordinate systems.
Lesson 2.8 The Coordinate Plane
Introduction to Graphing
Chapter 1: Linear Functions, Equations, and Inequalities
Parallel Coordinates and Scatter Plots
WINDOWING AND CLIPPING
Warmup NO CALCULATORS Convert into radians or degrees.
Digital Media Dr. Jim Rowan ITEC 2110.
Graphing & Describing “Translations”
P.5 The Cartesian Plane Our goals are to learn
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Frequency Distributions and Their Graphs
WINDOWING AND CLIPPING
c) Which athletic club costs more initially?
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
CNC Milling/Lathe interface Introduction
Algebra 1 Section 1.2.
10-5 Hyperbolas Hubarth Algebra II.
Getting Started with Milestone 2
Lesson 4-1 The Coordinate Plane.
2D Graphics Lecture 4 Fri, Aug 31, 2007.
Histograms Lecture 14 Sec Fri, Feb 8, 2008.
2 types of scale factor problems
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Window to Viewport Transformations
Transformations - Rotations
Presentation transcript:

COMP261 Lecture 4 Graphs 3 of 3

Outline Graph display Different coordinate systems Location class Redraw graph under movements

Program Summary Load the files Store the information into a graph Roads: roadID-roadInfo.tab Nodes: nodeID-lat-lon.tab Road segments: roadSeg-roadID-length-nodeID-nodeID-coords.tab Store the information into a graph Data structure needed Display (part of) the graph in the drawing area Redraw the graph after movements (e.g. left, right, zoom in/out)

Display Graph

Display Graph Important parameters Size of the drawing area Location of the drawing area Scale of the drawn graph (zoom in/out) Different coordinate systems Drawing area: 800x800 pixels Locations in graph: latitude/longitude, x/y kms, … Transformation Graph area ↔ Drawing area Use origin location + scale

Location vs Pixels. ORIGIN: pixel coordinates: 0, 0 location: 15490.5, -4092.899 SCALE: 800 pixels 97.5 km

Location Class Provided to help display Three representations of a location/place/point latitude/longitude Absolute location on a sphere This is what is in the data Location fields: x/y in kilometers Relative location to Aukland center x kms to the east, y kms to the north Assume Auckland region is a flat plane (not quite true, but good enough) This is what you need for finding shortest paths Point (x/y in pixels): pixel coordinates for drawing points and lines mouse click positions y (north) AukCenter x (east)

Location Class Read lat/lon from data Transform to x/y kms and store in the object Formula already provided in the class For display, transform x/y kms to pixel coordinates Current origin and scale Look at the Location.java

Display Graph public void drawLocations(Graph g, Location origin, double scale) { for each location in g: Point pt = location.asPoint(origin, scale); drawPoint(pt); } public Point asPoint(Location origin, double scale) { int u = (int) ((x - origin.x) * scale); int v = (int) ((origin.y - y) * scale); return new Point(u, v);

Redraw Graph Under Movements public Point asPoint(Location origin, double scale) { int u = (int) ((x - origin.x) * scale); int v = (int) ((origin.y - y) * scale); return new Point(u, v); } Drawing requires transforming from x/y kms or lat/lon to pixel coordinates Depends on origin and scale Move left/right/up/down change origin Zoom in/out change both origin and scale How to adjust origin?

Redraw Graph Under Movements Zoom in/out from the current center Zoom in: zoom < 1 Zoom out: zoom > 1 dy = (height – height * zoom) / 2 old origin new origin dx = (width – width * zoom) / 2 width * zoom height width New origin = (origin.x + dx, origin.y + dy)

Redraw Graph Under Movements Notice: use the same coordinate system for all the calculations x/y kms Need to get xmin, xmax, ymin, ymax Pixel coordinates Need to transform back from Point to Location See the method newFromPoint(Point point, Location origin, double scale) in Location.java

Redraw Graph Under Movements Using the x/y kms Get the pixel width and height of the drawing area vertices ← {(0,0), (0,height), (width, 0), (width, height)} for i = 0 to 3: loc[i] ← Location.newFromPoint(vertices[i], origin, scale) locWidth ← loc[2].x – loc[0].x locHeight ← loc[1].y – loc[0].y dx ← (locWidth – locWidth * zoom) / 2 dy ← (locHeight – locHeight * zoom) / 2 newOrigin.x ← origin.x + dx newOrigin.y ← origin.y + dy

Redraw Graph Under Movements Using pixel coordinates directly? How about zoom out?

Summary of Display Load the Road, Node, Segment files Use Location object to represent the locations of the nodes and segments Convert lat/lon to x/y kms in the objects Store into a graph object Use data structures discussed before Set proper initial origin location and scale (e.g. 1) Auto-display the loaded graph using the origin and scale Under any movement Recalculate the origin and scale (depending on movement) Redraw the graph using the new origin and scale