Computer Graphics Algorithms and Animation Principles
Posted by Anonymous and classified in Mathematics
Written on in
English with a size of 387.26 KB
Digital Differential Analyzer (DDA) Algorithm
- Input: The starting point (x1, y1) and ending point (x2, y2).
- Calculate:
- dx = x2 - x1
- dy = y2 - y1
- Find:
- Steps = max(|dx|, |dy|)
- Compute:
- xinc = dx / Steps
- yinc = dy / Steps
- Plot: The initial point.
- Iterate: Add xinc and yinc repeatedly until the endpoint is reached.
Bresenham's Line Drawing Algorithm
- Calculate dx and dy.
- Initialize the decision parameter.
- Plot the starting pixel.
- According to the decision parameter, choose the next pixel.
- Update the decision parameter.
- Repeat until the endpoint is reached.
Midpoint Circle Drawing Algorithm
- If P < 0, choose the East pixel.
- If P ≥ 0, choose the South-East pixel.
- Update the decision parameter.
- Continue until x > y.
- Use 8-way symmetry to complete the circle.
Sutherland-Hodgman Polygon Clipping
Definition
This algorithm is used to clip polygons against a rectangular clipping window.
Algorithm Steps
Process each polygon edge against every clipping boundary. There are four cases:
- Inside → Inside: Output the second vertex.
- Inside → Outside: Output the intersection point.
- Outside → Inside: Output the intersection point and the second vertex.
- Outside → Outside: Output nothing.
Flood Fill Algorithm
Fills connected pixels that have the same interior color.
Steps
- Start from a seed point.
- Replace the interior color.
- Move to neighboring pixels.
Boundary Fill Algorithm
Fills pixels until a specific boundary color is reached.
Steps
- Start inside the object.
- Fill pixels until the boundary color appears.
Graphical Kernel System (GKS)
Features
- Device independent: Works across different hardware.
- Portable: Easy to move between systems.
- Standard graphics functions: Provides a consistent API.
- Easy application development: Simplifies the coding process.
GKS Primitives
- Polyline
- Polymarker
- Fill Area
- Text
Applications
- Computer-Aided Design (CAD)
- Scientific visualization
- Graphics software development
Principles and Types of Animation
Animation is the process of displaying a sequence of images (frames) rapidly to create the illusion of continuous motion. In computer graphics, animation is used to make objects move, change shape, or simulate real-world motion.
Basic Principles of Animation
The basic principles of animation improve the realism and quality of animated objects:
- 1. Squash and Stretch: Gives flexibility and weight to objects. Example: A bouncing ball squashes when it hits the ground and stretches while moving upward.
- 2. Timing: Controls the speed and duration of movement.
- 3. Anticipation: Prepares the viewer for an upcoming action.
- 4. Follow Through: Parts of an object continue moving after the main object stops.
Types of Animation Systems
- Scripting Animation: Animation is controlled using scripts or programming languages, providing flexibility and automation.
- Procedural Animation: Motion is generated automatically using mathematical formulas or algorithms.
- Representational Animation: Objects are represented using mathematical or geometric models.
- Stochastic Animation: Uses random values and probability to generate natural-looking motion.