CG OpenGL polar curves & input display color-course 4

  • View

  • Download

Embed Size (px)


Design some polar curves & view color information on devices


  • Some polar curves Input devicesDisplay Color information Chen Jing-Fung (2006/11/22) Assistant Research Fellow, Digital Media Center, National Taiwan Normal University Video Processing Lab National Taiwan Normal University
  • Polar coordinates in xy plane r y axis y P : ( x, y ) s r x axis x Angle =s/r (radians/radius) Polar coordinate-> Cartesian coordinate x=r cos, y=r sin Inverse transformation 1 y r x y , tan ( ) 2 2 x Video Processing Lab 2
  • Cardioid polar plot The curve given by the polar equation The envelope of these circles is then a cardioid (PedoeThe name cardioid was first 1995).used by de Castillon inPhilosophical Transactionsof the Royal Society in 1741.Its arc length was found byla Hire in 1708. Video Processing Lab 3
  • The graph of the polar equation (1) Plot the polar equation The incredibly beautiful curve that results was discovered by Temple H. Fay. His article "The Butterfly Curve (American Mathematical Monthly, May 1989, p.442) is well worth a trip to the library.r ecos( ) 2cos(4 ) sin5 (1/12) Video Processing Lab 4
  • The graph of the polar equation (2) Six leaves: r=1+cos(t)/2 =t/6-sin(2t) X=r*cos() Y=r*sin() range: t = 0 ~ 12pi Video Processing Lab 5
  • How to drawpolar-coordinate picture Sector size Video Processing Lab 6
  • Input devices trigger Video Processing Lab National Taiwan Normal UniversityCh3: Interactive Computer Graphics: A Top-Down Approach using OpenGL, 3/e
  • Measure and Trigger Input devices provide input to an application program can be described: Measure process: The device returns to user program Trigger process: User can signal the computer Ex: Keyboard Measure: key a string Trigger: enter key Video Processing Lab 8
  • Describe modes Three distinct modes are defined by the relationship between the measure process and the trigger. Request mode, sample-mode and event mode Example: The position of a mouse: tracked continuously by the underlying window system Whether the application program needs or not mouse input. Video Processing Lab 9
  • Request mode The measure of the device is not returned to the program until the device is triggered. The input mode is standard, such as: C , C++, .program Input the scanf: the program halts before we type characters at our terminal. Each data is placed in keyboard buffer enter key (the trigger) is depressed Request Trigger Measure process Program Trigger process Measure Video Processing Lab 10
  • Sample mode Input is immediate. (simple type of request mode) As soon as the function call in the user program is encountered, the measure is returned. Left Click is depressed Sample Measure Program process Measure Video Processing Lab 11
  • Event mode (1) Handle other interactions: How event mode can be described as another mode within our measure-trigger. (How) Basic of client and servers where event mode is the preferred interaction mode. (where) Event-mode interface to OpenGL using GULT Video Processing Lab 12
  • Event mode (2) Event is generated: Each time that a device is triggered Device measure: The identifier for the device is placed in an event queue. Await Trigger Measure Event Program process Trigger process queue Measure Event Video Processing Lab 13
  • OpenGL Input device function Input device: Mouse & keyboard To extract the current raster position window management function glutMouseFunc(myMouse); and glutKeyboardFunc(key); User define OpenGL mouse event (GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON ) OpenGL keyboard event (each key on keyboard can be used) Location of mouse: left-down Video Processing Lab 14
  • Display Color information Video Processing Lab National Taiwan Normal UniversityCh4: Computer Graphics with OpenGL 3th, Hearn Baker
  • Graphics system Attribute parameter Determine the fundamental characteristics Color and size Specify how the primitive is to be displayed under special conditions Visibility or detectability within an interactive object- selection program The current frame-buffer position state variables glBegin . glEnd state parameters from one coordinate position to another Video Processing Lab 16
  • Color Color information: RGB: Resolution=1024x1024, Full color=24- bit/pixel, Frame buffer=3 megabytes Magenta Blue Red Cyan Yellow Green Gray scale: Ex: objects shade Video Processing Lab 17
  • Color table Color lookup table monitor 0 y 196 196 0x0821(2081) x 255To Red Gun To Green Gun To Blue Gun Each 8-bit segment of this entry controls the00000000 00001000 00100001 intensity level of one of the three electron guns in an RGB monitor Video Processing Lab 18
  • Pixel-array primitives Graphics packages often supply routines to display shapes Defined with a rectangular array of color values Display: digitizing (scanning). Each color value in the array is mapped to one or more screen pixel positions. Typically referred to as a pixmap. Pixel array: color and size Video Processing Lab 19
  • y OpenGL bitmap ymaxfunction (same color) ymin x xmin xmax The pixel-array is simply a bitmap, which is also called a mask. OpenGL binary array pattern: glBitmap width and height: the number of columns and rows in the array bitShape x0 and y0: the start position of the array bitShape, (x0,y0): oppos