1 / 12

Coordinate Systems (3.1-3.2)

Coordinate Systems (3.1-3.2). Device coordinates, or screen coordinates (pixels) put limitations on programmers and the code is not portable generally expressed in integers World coordinates

rsherwood
Download Presentation

Coordinate Systems (3.1-3.2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Coordinate Systems (3.1-3.2) • Device coordinates, or screen coordinates (pixels) • put limitations on programmers and the code is not portable • generally expressed in integers • World coordinates • an effort was made to hide the actual device coordinates from the programmer and allow ANY coordinate to be used • generally expressed in floats • programmer defines world space • Mapping • the mathematical transformation from one coordinate system to another • involves relatively simple algebra • See page 85 for one option

  2. Mapping • Convert from world coordinates to viewport coordinates • Proportional along the x-axis and y-axis • Values needed • Window left, right, bottom, top • Viewport left, right, bottom, top • Sx = VL + ((Wx - WL)/Wr - WL) * Vr - VL) • Sy = Vb + ((Wy - Wt)/Wt - Wb) * (Vt - Vb) • Example • Device coordinates of 640 x 480 • World coordinates of 5000 x 4000 • Map (2500, 2000) to ___________ • Map (1000, 1000) to ___________

  3. Viewing • Viewing rectangle or window • items within the window will be seen and others will be clipped • 3D Viewing Volume • glOrtho(left,right,bottom,top,near,far) • Be aware of right handed coordinate system • positive Z comes out from screen • Viewport • a rectangular region within the window • glViewport(x,y,width,height) • Aspect Ratio • the ratio of the viewing rectangle should be the same as the viewport

  4. Mapping in OpenGL • Primitives are multiplied by matrices before being displayed. • OpenGL has two important matrices • MODELVIEW - for viewing parameters • PROJECTION - for display parameters • Typical initialization • glMatrixMode(GL_PROJECTION); • glLoadIdentity(); • glOrtho(left, right, bottom, top); • glViewport (left, bottom, width, height); • glMatrixMode(GL_MODELVIEW); • Leave in MODELVIEW mode • OpenGL handles the mapping and clipping of points • Demo • viewport.c

  5. Animation 3.2 • repeatedly draw images to create the illusion of motion • this may cause flicker though • solution is double buffering • draw images in the back buffer • display images in the front buffer • swap when ready to display • glutSwapBuffers(); • Let OpenGL know • glutInitDisplay (GLUT_DOUBLE | GLUT_RGB); • Demo • single_double.c • Zooming and Panning • Adjust window coordinates as needed for different effects

  6. Canvas class (3.4) • Author’s class to support to 2D rendering • My version is available at • ~grissom/367/Canvas.c • Must create a global variable • Canvas cvs (640, 480, “title); • Instance Variables • CP - current position (x, y) • CD - current direction (angle) • Methods • setWindow (left, right, bottom, top) • setViewport (left, right, bottom, top) • clearScreen ( ) • setBackgroundColor(r, g, b) • setColor (r, g, b) • moveTo (x, y) • lineTo (x, y)

  7. Relative Drawing (3.5) • Methods • moveRel (x, y) • lineRel (x, y) • Group Activity • draw stairs

  8. Turtle Graphics (3.5) • Methods • turnTo (angle) • turn (angle) • forward (dist, isVisible) • Angles • positive rotation is CCW • starts a degree zero on X-axis • human uses degrees • computer uses radians (2 π) • Group Activity • draw a star

  9. Polygons • Calculate the points based on angle • Convert degrees to radians • formula? • x = radius * cos(angle) + center.x • y = radius * sin(angle) + center.y • Group Activity • draw a hexagon

  10. Input Devices • Physical devices • Pointing devices - Mouse, ligth pen, microphone, trackball, joystick • Keyboard device - keyboard • 3D input - laser scanners, VR helmets, data gloves • Logical devices • not related to a specific physical device • device independent just like cout statements • String - sequence of ASCII characters • Locator - returns XY position • Pick - returns ID of a selected object • Choice - one of a limited number of options (menu) • Dial - valuator, returns analog values (slidebars) • Stroke - a series of points or vectors

  11. Usability Design Guidelines • Usability Engineering • Objectives • Reduce errors • Improve performance • Ease of use • Attractive • Examples • Nothing is every as easy to use as the designer thinks it is • EDIT (select everything, delte, insert T) • Delete everything or cancel this request? • YES or NO • Remove the diskette from the protective cover • Press any key to continue • Usability Testing is a must • Watch typical users • It can be frustrating

  12. Usability Measures • Number of errors • Performance time • User satisfaction • Ability to customize

More Related