Computer GraphicsUnit 710 min read
3D Coordinates, Transformations & Hierarchies
Unit 7 of Computer Graphics covers the mathematical foundations of 3D space—coordinate systems, homogeneous coordinates, and transformations (translation, rotation, scaling)—along with their applications in modeling hierarchies (e.g., skeletal animations) and real-world systems like game engines and CAD tools.
TAKEAWAYS:
- 3D coordinates use and homogeneous coordinates to represent points, vectors, and transformations uniformly.
- Transformations (translation, rotation, scaling) are matrices applied to objects or the camera/viewer; they follow the right-hand rule and matrix multiplication order.
- Hierarchical modeling breaks objects into parent-child relationships (e.g., a robot’s arm rotating around its shoulder) using local-to-world transformations.
- Composite transformations combine multiple operations (e.g., rotate then translate) into a single matrix for efficiency.
- Real-world use: Games (e.g., Pathao’s 3D delivery maps), CAD (e.g., NTC’s infrastructure modeling), and animation (e.g., YouTube’s 3D avatars).
- Exam focus: Derive transformation matrices, apply them to points, and explain hierarchical modeling with examples.
1. 3D Coordinate Systems
In 2D, we use ; in 3D, we add for depth. The right-hand rule defines axes:
- Thumb: (right)
- Index: (up)
- Middle: (out of screen)
Key terms:
- Point: A location .
- Vector: A direction (e.g., from point A to B).
- Normal vector: Perpendicular to a surface (used in lighting).
Worked Example: Convert the point to homogeneous coordinates (used for transformations): Why? Homogeneous coordinates unify points and vectors into a single matrix framework.
2. Basic 3D Transformations
Transformations move, rotate, or scale objects using 4×4 matrices. The general form for a point is:
A. Translation (Moving Objects)
Moves an object by : Example: Move a cube from to :
B. Rotation (Around Axes)
Use the right-hand rule to determine rotation direction.
Rotation about X-axis (θ degrees): Example: Rotate by around :
Rotation about Y-axis:
Rotation about Z-axis:
Worked Example (Composite Rotation): Rotate by around , then around :
- Apply :
- Apply : Result: moves from to .
C. Scaling (Resizing Objects)
Scales by factors : Example: Scale by :
3. Matrix Multiplication Order
Transformations are applied right-to-left (matrix multiplication is not commutative): Example: Translate then rotate vs. rotate then translate:
- Translate then rotate:
- Rotate then translate: Result: Different final positions!
4. Hierarchical Modeling
Objects are modeled as trees where:
- Parent nodes define local transformations.
- Child nodes inherit transformations from parents.
Example: A robot arm with 3 joints:
- Shoulder (root): Translates to .
- Elbow (child of shoulder): Rotates around -axis by .
- Hand (child of elbow): Translates by .
graph TD
A["Shoulder"] --> B["Elbow"]
B --> C["Hand"]
A -->|"Local: T(0,0,0)"| D["World"]
B -->|"Local: R_y(45°)"| D
C -->|"Local: T(0,0,2)"| DGlobal Transformation:
Real-World Tie-In:
- Pathao’s delivery maps: Uses hierarchical transformations to model moving vehicles and dynamic routes.
- 3D game characters: Skeletons (e.g., a knight’s armor) are parented to bones for realistic movement.
5. Composite Transformations
Combine multiple transformations into a single matrix for efficiency. For example, rotate then translate: Example: Rotate by around , then translate by :
- Compute :
- Compute :
- Multiply :
- Apply to :
6. Applications in Real World
A. E-Sewa & Government Services
- 3D modeling of infrastructure: NTC uses transformations to simulate power line routes in 3D space before construction.
- Virtual tours: E-Sewa’s citizen portals could use 3D transformations to show office layouts for appointments.
B. Gaming & Animation
- Pathao’s driver app: Uses hierarchical transformations to model moving vehicles and dynamic traffic routes.
- YouTube’s 3D avatars: Avatars are built using skeletal hierarchies (e.g., head rotates around neck).
C. CAD & Engineering
- Nepal’s NEPSE stock visualization: 3D charts use transformations to rotate and scale graphs for better analysis.
- Robotics: A robot arm’s movements (e.g., in industrial automation) rely on inverse kinematics and hierarchical transformations.
7. Common Pitfalls & Exam Tips
| Mistake | Correct Approach | Exam Hint |
|---|---|---|
| Wrong matrix multiplication order | Remember: right-to-left (e.g., ). | Always write transformations in order of application. |
| Confusing rotation axes | Use the right-hand rule for direction. | Draw axes and thumb/index/middle fingers. |
| Forgetting homogeneous coordinates | Always use for points. | Write explicitly. |
| Hierarchy misalignment | Parent transformations must be applied first. | Draw the tree and label local/global. |
| Scaling non-uniformly | Check if . | State whether scaling is uniform or non-uniform. |
Exam Tip:
- Derive matrices: Show every step (e.g., trigonometric values for rotations).
- Visualize: Sketch the object before/after transformations.
- Hierarchy questions: Always show the tree and compute global transformations step-by-step.
8. Summary Table: Transformations
| Transformation | Matrix Form | Key Parameters | Example Use Case |
|---|---|---|---|
| Translation | Diagonal | Moving a car in a game. | |
| Rotation (X-axis) | in rows 2-3 | Angle | Spinning a planet around its axis. |
| Rotation (Y-axis) | in cols 1/3 | Angle | Tilting a robot’s head. |
| Rotation (Z-axis) | in cols 1/2 | Angle | Rotating a 2D sprite in a game. |
| Scaling | Diagonal | Zooming into a map. | |
| Composite | Product of individual matrices | Order matters! | Animating a skeleton. |
9. Worked Example: Daraz Delivery Route
Scenario: A Daraz delivery person starts at , moves 5 units east (), then turns left (around ) and moves 3 units north ().
First translation (east): New position: .
Rotation (90° left around ): Apply to :
Second translation (north): Final position: .
Visualization:
10. Real-World Picture: Robot Arm
graph TD
A["Base"] --> B["Shoulder"]
B --> C["Elbow"]
C --> D["Wrist"]
D --> E["Gripper"]
A -->|"T(0,0,0)"| F["World"]
B -->|"R_y(θ₁)"| F
C -->|"T(0,0,L₁) + R_y(θ₂)"| F
D -->|"T(0,0,L₂) + R_y(θ₃)"| F
E -->|"T(0,0,L₃)"| F11. Exam Tip: Matrix Derivation
For exams, always:
- Write the general matrix form.
- Substitute given values (e.g., ).
- Multiply step-by-step (show intermediate results).
- Apply to a test point (e.g., ) to verify.
Example Question: "Derive the matrix to rotate a point around the -axis and then translate it by ." Solution:
- :
- :
- Composite :
- Apply to :
Based on the PU BE Computer (PU) syllabus for Computer Graphics, unit 7.
Discussion
Loading…