GPNOTES Unit 1
GPNOTES Unit 1
It is a type of transformation that moves an object from one location to another without altering its shape,
size, or orientation. It shifts all points of an object by the same distance in a given direction.
Translation in 2D
In 2D translation, an object is moved along the x and y axes.
● Translation matrix for 2D space:
Where:
● txt is the translation along the x-axis.
● ty is the translation along the y-axis.
Translation in 3D
In 3D translation, an object is moved along the x, y, and z axes.
Translation matrix for 3D space:
Where:
● tx is the translation along the x-axis.
● ty is the translation along the y-axis.
● tz is the translation along the z-axis.
Shear transformation:
A transformation that slants the shape of an object. In 3D, an object can be sheared along the X-axis, Y-axis, or
Z-axis
Applications of Translation
2D Translation: Moving a character or object across the screen in a 2D game.
3D Translation: Shifting objects in a 3D modeling environment or moving the camera in a 3D scene.
Translation is one of the simplest and most common transformations in graphics, often combined with other
transformations like rotation and scaling to create complex motion and positioning.
1. One-Point Perspective:
o Only one vanishing point is present.
o Typically used for scenes where objects are viewed head-on (e.g., looking down a hallway).
2. Two-Point Perspective:
o Two vanishing points are used.
o Commonly used for objects viewed from an angle, where both the horizontal and vertical lines
of the object converge towards two separate vanishing points.
3. Three-Point Perspective:
o Three vanishing points are used (one for horizontal, one for vertical, and one for depth).
o This method is used when the object is viewed from a high or low angle, creating a more
dynamic sense of space.
2D transformations can be combined in a sequence to create more complex effects. For example, a
combination of translation, rotation, and scaling can animate an object's movement, rotation, and resizing.
Q6. write a short note on direction cosines.
Direction cosines are the cosines of the angles that a vector makes with the positive directions of the
coordinate axes. They are important in various fields, such as physics and engineering, to describe the
orientation of a vector in 3D space.
.
Direction Cosines and Direction Ratios of a Line
Let’s assume a line OA that is passing through the origin and makes angles α, β, and γ with x, y, and z-axis
respectively, called direction angles. The cosines of these angles cos(α), cos(β), and cos(γ) are called directional
cosines of the directed line OA. The figure given below shows the line OA passing through the origin and all the
angles it makes with the coordinate axes.
Pythagoras' Theorem in 3D
In 3D space, Pythagoras' Theorem can be extended to find the distance between two points or the length of
the diagonal in a rectangular cuboid. For a right-angled triangle in 3D, the square of the length of the diagonal
(or hypotenuse) is equal to the sum of the squares of the three perpendicular sides.
● For a cuboid with sides a, b, and c, the diagonal d is: (write)
Applications of Pythagoras' Theorem
1. Distance Calculation: Pythagoras' Theorem is used to calculate the distance between two points in
both 2D and 3D space.
2. Computer Graphics: In 3D modeling and rendering, it helps calculate distances, lengths, and angles for
object placement, camera movements, and collision detection.
Q8. Explain how dot product is used in calculation of back face detection.
Answer in assignment ( learn diagram)
Rotational Representation:
● When using Euler angles (pitch, yaw, roll) to describe rotations, these angles are applied sequentially.
For example:
o Pitch: Rotation about the x-axis.
o Yaw: Rotation about the y-axis.
o Roll: Rotation about the z-axis.
● Gimbal lock occurs when two of the three rotation axes become aligned, causing the loss of one degree
of freedom.
● For example, if the pitch is rotated by 90 degrees, the yaw and roll axes may align, making it impossible
to rotate around one of those axes independently.
● This results in a situation where you cannot achieve certain orientations that would normally be
possible, leading to unexpected behavior in the object's rotation.
● 3D Animation and Modeling: Animators may find it challenging to achieve certain rotations, leading to
jittery or unintended motion.
● Game Development: When using Euler angles for camera or character rotations, gimbal lock can hinder
smooth transitions and control.
● Robotics: In robotics and motion control, gimbal lock can lead to control issues and instability in
movement.
Memory Larger cache, optimized for fast access High bandwidth memory for fast data throughput
Handles complex logic and control Handles massive amounts of data in parallel, ideal
Task Handling
tasks for rendering
Power
Typically lower in idle state Can be higher under load due to parallel processing
Consumption
Applications of GPUs
1. Gaming:
o GPUs are vital for rendering high-quality graphics in video games, providing smooth frame rates
and realistic visuals.
2. Video Editing:
o GPUs accelerate video processing, enabling real-time editing and effects rendering.
Diffuse Light
Definition
Diffuse light is the type of light that scatters uniformly in all directions when it strikes a rough surface. Unlike
ambient light, diffuse light interacts with the surface material to produce color and brightness based on the
angle of incidence.
Diffuse reflection occurs on the surfaces which are rough or grainy. In this reflection the brightness of a point
depends upon the angle made by the light source and the surface.
Specular Light
Definition
When light falls on any shiny or glossy surface most of it is reflected back, such reflection is known as Specular
Reflection. Phong Model is an empirical model for Specular Reflection which provides us with the formula for
calculation the reflected intensity
2D Shearing
Shearing is a transformation that distorts the shape of an object by slanting it in a particular direction. This
transformation changes the coordinates of the points of the object according to specific shearing factors.
Applications
● Creating slanted text or graphics.
● Simulating the effect of perspective in illustrations.
● Manipulating shapes in computer graphics for various design purposes.
● Bounding Volume: Objects can be encapsulated in bounding volumes (e.g., bounding boxes or spheres)
to perform quick checks against the frustum. If the bounding volume does not intersect with the
frustum, the object can be culled.
Clipping
Definition
Clipping is the process of constraining rendering to a defined area or region of interest. It involves removing
portions of objects that fall outside a specified boundary (known as the clip window or clip region). This
ensures that only visible parts of objects are processed and rendered.
Benefits of Clipping
● Performance Enhancement: By eliminating parts of objects outside the viewing area, clipping reduces
the number of calculations required for rendering, leading to faster performance.
● Memory Efficiency: Clipping ensures that only necessary geometry is processed, helping to manage
memory usage effectively.
Q16.Write a short note on RayTracing.
Ray tracing is a rendering technique used to create realistic images by simulating the behavior of light as it
interacts with objects in a scene. Unlike traditional rasterization methods that render images in a more direct
manner, ray tracing traces the paths of individual rays of light, allowing for complex lighting effects, shadows,
and reflections.
Ray Tracing Process
1. Ray Generation:
Rays are cast from the camera into the scene, with a primary ray
generated for each pixel to identify visible objects.
2. Intersection Tests:
Each primary ray is tested for intersections with objects in the
scene (e.g., spheres, planes). The closest intersection point
determines the visible object.
3. Shading:
At the intersection point, the color and brightness are computed using:
Ambient Light: Base color.
Diffuse Reflection: Light scattering based on the surface normal and light direction.
Specular Reflection: Highlights based on the viewer's position and light source.
4.Shadow Rays:
Rays are cast from the intersection point to each light source. If a shadow ray hits another object before
reaching the light, the point is in shadow, reducing its color contribution.
5.Reflection and Refraction Rays:
o Reflection Rays: Cast according to the surface normal to simulate reflections.
o Refraction Rays: Cast based on Snell's Law to simulate bending of light in transparent materials.
6. Recursive Ray Tracing:
For complex scenes, reflected and refracted rays may generate new rays, tracing them up to a set recursion
depth.
Here, the cosine and sine functions determine the new coordinates of the points after rotation. When applied
to a point (x, y), this matrix calculates the new position (x', y') of the point after rotation.
Usage:
Rotation is commonly used in various applications, including animation (e.g., rotating characters or objects),
game development (e.g., turning vehicles or camera views), and simulations.
Where sx and sy are the scale factors along the x-axis and y-axis, respectively. A scale factor greater than 1 enlarges the
object, while a factor less than 1 reduces its size.
Where tx and tyare the translation distances along the x-axis and y-axis, respectively. Applying this matrix to a
point (x, y) results in a new position (x', y').
Usage:
Translation is fundamental in graphical applications for moving objects across the screen. It is used in
animations to create motion effects, reposition elements in user interfaces, and manipulate camera views in
3D environments, enabling intuitive interactions for users.