Professional Documents
Culture Documents
Displays
Sensory
Speakers
Input Rendering
Force-feedback
Cognition Modeling
Geometry + Numbers
• introduced by Rene Descartes (1596-1650)
• started the Northern Renaissance
Dimension
• numbers : ordering <, =, >
• space : left-of, coincident, right-of
• multi-dimensional
—multiple independent but simultaneous dimensions
Coordinates
• tuples of values
—one value per dimension : ( x,y ) or ( x,y,z )
Functions
Mappings
• points -> points
• domain -> range
—can differ in dimension & coordinate systems
Equations
• explicit : y = x*m + b
• implicit : r2 = x2 + y2
• parametric : P = t*P1 + P0
Uses
• shape : all points that satisfy some equation
• motion : change in position as a function of time
• transforms : mapping a space onto itself, i.e. domain = range
Digital Numbers
Integers
• base 2 string of binary digits : 98 = 1100010
• 8-bit (byte), 16-bit (short), 32-bit (int), 64-bit (long)
Reals
• fixed point
—5.75 -> 101.110
• floating point
—scientific notation -> 2.25 * 103
—fraction (mantissa) + exponent -> 5.75 -> .101110 * 2 3
—precision
– single (float) : 32-bit -> 24-bit mantissa + 8-bit exponent
– double : 64-bit -> 56-bit mantissa + 8-bit exponent
Digital Points
Coordinates
• number of coordinates == dimension of space
• need one number per coordinate
• number can be any digital number (int, float, etc.)
Java2D Class Constructors
• java.awt.Point( int x, int y ) - discrete space
• java.awt.geom.Point2D.Float( float x, float y )
• java.awt.geom.Point2D.Double( double x, double y )
Digital Lines
Lines
• 1D, continuous, straight (not curved)
• infinite length, unbounded
Line Segments
• finite subset of a line
• definable by two end-points
Java2D Class
• java.awt.geom.Line2D
Line Equations
Explicit
• y = mx + b, slope/y-intercept form
Implicit
• 0 = Ax + By + C, normal/distance form
Parametric
• P = P1 * (1-t) + t * P2, weighted sum form
• P = O + D*t, directed ray form
Transformations
Purpose
• make global geometric changes
• restricted to use of linear equations in CG
Elementary Transforms
• Translation - change in position
• Rotation - change in orientation
• Scaling - change in size
• Shearing - change in perpendicularity
Combinations
• any sequence of elementary transformations can be used
• order of transforms matters in most cases
Classes of Transformations
Rigid Body
• preserves distances and angles
• translation & rotation
Affine
• preserves parallel lines
• all 4 elementary transformations
Projective
• preserves straightness/flatness
• affine + perspective
Linear
• rotation, scaling and shearing
Translation
Geometry
• change only in position
—relative to the origin or to other shapes
Vector/Linear Algebra
• is vector addition
• P’ = P + T, where T is the translation vector
Properties
• identity, inverse, closure, commutative
Rotation
Geometry
• change in orientation
• by some angle A either CCW or CW
• about a some point (in 2D)
Properties
• identity, inverse, closure, commutative
• fixed point
Algebraic form
• x’ = x * cos A - y * sin A
• y’ = x * sin A - y * cos A
Scaling
Geometry
• change in size
• change in aspect ratio
• change in handedness
• projection
Algebra
• x’ = x * Sx
• y’ = y * Sy
• Sx == Sy => symmetric scaling
• Sx != Sy => asymmetric scaling
Shearing
Geometry
• change in perpendicularity
• introduces slant
Algebra
• in X
—x’ = x + y * Shx
—y’ = x * Shy + x
Display of Motion
Create visual perception of motion
• movies, TV, interactive graphics
• sequence of snap shots : frames
• played back rapidly at a constant frame rate
Variety of frame rates
• Film : 24 fps (frames per second)
• S-TV: 30 fps
• HD-TV: 60 fps
• Computers : 60-120 fps
Interactive Animation
Demands
• constant display rate
• no pre-computed frames
—all images synthesized dynamically
—need fast interactive response time : < 50ms
Issues
• rendering time varies per frame
—depends on quantity of geometry and sophistication of rendering
• display fps != rendering fps
—distance moved per rendered frame should depend upon rendering
time to create illusion of constant rate motion
Interactive Animation
Solutions
• Frame Buffers
—holds a single frame as a digital-image
—used to drive the display at constant frame rate
—decouples rendering rate from display rate
Problems
• rendering process will be visible
—buffering clearing
—multi-frame rendering times
Double Buffering
Separate Rendering from Display
• use two buffers, one “on-screen” and one “off-screen”
• sequence
—display from on-screen buffer while rendering into off-screen
buffer
—swap buffers quickly when rendering is completed
Methods
• Blt - copy off-screen to on-screen
• Flip - switch which buffer display processor reads
Displays
Monitors
• CRT’s - cathode ray tube
—electron beam hits phosphors
—image is drawn left-to-right, top-to-bottom
• LCD
—light source : backlit or reflected
—opacity of surface is modulated
Latest
• LED - light emitting diode
• Plasma - charged gas
• DLP - laser + mirrors
Pixels
Picture Element
• smallest area of digital color
displays : light emitting
cameras : light sensing
• uses Red-Green-Blue color components
—analogue of cones in the retina
Displays & Cameras
Use 2D array of pixels
–uniform distribution
Resolutions
• displays
— SDTV : 480 x 640
— HDTV : 1080 x 1920
— computers : adjustable
• cameras
— “high res” : 1200 x 1600
Aspect ratio
• height / width OR width / height
• square pixels only
• displays
— SDTV : 3 / 4
— HDTV : 9 / 16
Digital Images
2D Array of pixels
• pixels are digitally represented in memory
• each pixel has red-green-blue components
—numbers -> brightness
Resolution
• spatial resolution : width (X) & height (Y)
• color resolution (bits per pixel)
—1-bit -> bi-level bitmap (white or black)
—3-bits -> corners of color cube
—color -> 3 x component-resolution
– 8-bit integer per component -> 24-bit RGB
– 32-bit float per component -> 96-bit RGB
Frame Buffers
Display Image
• used to drive display
• holds a single digital
image, i.e. a frame
• used to map logical to
physical pixels
Display Refresh
- physical pixel output
decays rapidly
needed to see sequence of
frames
• refresh rates
—30 - 120 fps
Light
Photons
• all light is comprised of photons
• properties: velocity, wavelength, frequency, polarization
wavelength = velocity / frequency
• interact with matter : transmitted, reflected, absorbed
Spectral Distribution
• # of photons at each frequency/wavelength
• visible spectrum
Visual Perception
Retina
• 2D array of photo receptors; 7 million
• rods : low illumination, B&W (grey scale)
• cones : medium-high illumination, color
Photo Receptors
• measure light intensity (counts photons)
• sensitivity is frequency dependent
Cones
Types
• “red”, “green”, “blue”
Color Perception
Photo receptor activation level -> brightness
Combinations of cone activation
1. one wavelength -> “rainbow colors”
2. two wavelength -> rainbow + purples (hues)
3. all cones at equal activation -> white (grey)
4. arbitrary spectral distribution
– hue
– purity/saturation (complement of whiteness)
– brightness/lightness/value
Color Cone
Hue
Cyan
Magenta
Black
White
Red
Green
Yellow
Retina
Shapes
• interior is a solid which has volume
• boundary is a surface
—defined piecewise
• surface algorithms more complicated than for curves
—e.g. set operations, collision detection
3D Curved Surfaces
Implicits
• polynomials define interior, boundary and
exterior
• sphere :
x2 + y2 + z2 = r2
Parametrics
• many Bezier curves used to define a single
surface
• recursive subdivision used to create triangle
mesh approximation
Polyhedra
Boundary
• piecewise linear
—each piece is called a “face” or “facet”
• if closed => solid
—polyhedra proper are closed
—polyhedral meshes may be open
Use
• real-time graphics is all polyhedral
—hardware only draws triangular meshes
• can approximate any curved surface arbitrarily well
—often combined with “smooth shading”
Polytopes
Dimension independent concept
3D polyhedra
2D polygons
1D line segments
0D point
Boundary : recursive definition
• d-polytope bounded by set of (d-1)-polytope
—d is the dimension, stops at d == 0
3D Transformations
Categories : same as 2D
• types
—rigid body, affine, projective, linear
• elementary
—translations, rotation, scaling, shearing
Representations
• change of vector basis
P = x * [X] + y * [Y] + z * [Z] + T
• matrices : 4x4
3D Translation
Change in 3D position
• T = [ x y z]T
• P’ = P + T
x’ = x + Tx 1 0 0 Tx
y’ = y + Ty 0 1 0 Ty
z’ = z + Tz 0 0 1 Tz
w’ = w 0001
3D Scaling
Analogous to 2D
• change in size, aspect ratio, projection,
reflection
x’ = x * Sx Sx 0 0 0
y’ = y * Sy 0 Sy 0 0
z’ = z * Sz 0 0 Sz 0
w’ = w 000 1
3D Rotation
Rotation as change of vector basis
• preserve :
—length
no change is length of each vector basis
—perpendicularity
between every pair of vector bases
called orthogonal vector basis
• called orthonormal transformation
3D Rotation
Rotation about a coordinate axis
ex: rotation about z-axis
x’ = x * cos - y * sin cos -sin 0 0
y’ = x * sin + y * cos sin cos 0 0
z’ = z 0 0 1 0
w’ = w 0 0 0 1
similar for about x-axis or y-axis
3D Rotation
Rotation can be define about any line
1. transform arbitrary line (axis of rotation) onto a coordinate axis
2. apply desired rotation (now about a coordinate axis)
3. transform line back to original position : invert (1)
AxisAngle
Class in Java3D
aa = new AxisAngle4d( Vector3d axis, double angle )
m = new Matrix3d() ; m.set( aa );
Quaterions
Good for interpolation between rotations
q == [ axis * sin /2, cos /2 ]
q = new Quat4d(); q.set( AxisAngle aa );
3D Shearing
Shearing in Z
x’ = x + Shx 1 0 Shx 0
y’ = y + Shy 0 1 Shy 0
z’ = z 0 0 1 0
w’ = w 0 0 0 1
Leaf nodes
• Shape3D - Geometry & Attributes
• Lights, Views, Sounds
+ specialized functions : e.g. Fog, Background
Behaviors for animation & interaction
Java 3D Execution
Definition phase
• executes your code that defines the scene graph
• no restrictions on what values can be set
Live phase
• Java 3D engine processes scene graph for each
frame
—updates values controlled by behaviors
• Capability bits
—protects what can be modified at runtime