Unit-1 DirectX Pipeline and Programming (E-Next - In)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

GP QB Unit 1

1. Explain in detail the Cartesian xy-plane.


• The Cartesian xy-plane provides a mechanism for translating pairs
of related variables into a graphical format.
• The variables are normally x and y, as used to describe a function
such as y = 3x+2.
• Every value of x has a corresponding value of y, which can be
located on intersecting axes.
• The set of points forms a familiar straight line associated with
equations of
• the form y = mx+c.
• By convention, the axis for the independent variable x is horizontal,
and the dependent variable y is vertical.
• The axes intersect at 90◦at a point called the origin.
• Measurements to the right and left of the origin are positive and
negative
• respectively, and measurements above and below the origin share a
similar
• sign convention.
• Together, the axes are said to create a left-handed set of
• axes, because it is possible, using one’s left hand, to align the
thumb with the x -axis and the first finger with the y-axis.
• Any point P on the Cartesian plane is identified by an ordered pair
of
• numbers (x, y) where x and y are called the Cartesian coordinates
of P.
• Mathematical functions and geometric shapes can then be
represented as lists of coordinates inside a program.

https://E-next.in
2. Write a short note on Theorem of Pythagoras in 2D.
• Pythagoras proved that the squared length of a plus the squared
length of b equals the squared length of c if a, b and c form a
triangle where angle ab is 90°.
• This results in the equation: 𝑎 2 + 𝑏 2 = 𝑐 2
• Solved for c it gives: 𝑐 = √( 𝑎2 + 𝑏2)
• We can calculate the distance between two points by applying the
theorem of
Pythagoras.


Figure 5.4 shows two arbitrary points P1(x1, y1) and P2(x2, y2).
• The distance Δx = x2−x1 and Δy = y2−y1 Therefore, the distance d
between
P1 and P2 is given by : d = √(Δx2 +Δy2)
• The Pythagorean theorem can be used for calculating the absolute
speed with the x- and y-speed as inputs

3. Write a short note on Theorem of Pythagoras in 3D.


• The theorem of Pythagoras in 3D is a natural extension of the 2D
rule.
• Given two arbitrary points P1(x1, y1, z1) and P2(x2, y2, z2),
the distance Δx = x2 − x1,Δy = y2 − y1 and Δz = z2 − z1.
• Therefore, the distance d between P1 and P2 is given by d =√(Δx2
+Δy2 + Δz2)

https://E-next.in
4. Explain Euler’s Rule with suitable example.
• In 1619, Descartes discovered quite a nice relationship between
vertices, edges
and the faces of a 3D polygonal object: faces + vertices = edges +
2
• As a simple test, consider a cube; it has 12 edges, 6 faces and 8
vertices, which
satisfies this equation.
• This rule can be applied to a geometric database to discover
whether it contains any spurious features.

5. Explain in detail 3D vector manipulation.


• As vectors are different from scalars, a set of rules has been
developed to
control how the two mathematical entities interact with one
another.
• Multiplying a Vector by a Scalar
o Given a vector n, 2n means that the vector’s components are
doubled. For example, if
n = [2 4 6] then 2n =[4 8 12]
o Similarly, if we divide n by 2, it becomes [1 2 3].
o Note that the vector’s direction remains unchanged – only its
magnitude changes.
• Vector Addition and Subtraction
o Given vectors r and s, r ± s is define as
r = [xr yr zr] s = [xs ys zs] r ± s =[xr±xs
yr±ys zr±zs]
o Vector addition is commutative:
a+b=b+a
eg: [1 2 3] + [4 5 6] = [4 5 6] + [1 2 3] = [5 7 9]
o However, like scalar subtraction, vector subtraction is not
commutative:
a−b≠b–a
o eg: [1 2 3] - [4 5 6] ≠ [4 5 6] - [1 2 3]

https://E-next.in
6. Explain the following terms-
a. Position Vectors
b. Unit Vectors
c. Cartesian Vector
• Position Vectors
o Given any point P(x, y, z ), a position vector p can be created
by assuming
o that P is the vector’s head and the origin is its tail.
o Because the tail coordinates are (0, 0, 0) the vector’s
components are x, y, z.
o Consequently, the vector’s magnitude ||p|| equals √ (x2 + y2
+ z2).
o For example, the point P(4, 5,6) creates a position vector p
relative to the origin:
o p =[4 5 6] ||p|| = √ (42 + 52 + 62) = 20.88
• Unit Vector
o By definition, a unit vector has a magnitude of 1 i.e. i = [1
0 0] ||i|| = 1
o Unit vectors are extremely useful when we come to vector
multiplication.
o Converting a vector into a unit form is called normalizing and
is achieved by dividing a vector’s components by its
magnitude.
o To formalize this process,
consider a vector r whose components are x, y, z.
The magnitude ||r|| = √ (x2 + y2 + z2) and the unit
form of r are given by
ru = 1 [x y z]
||r||
• Cartesian Vector
• To begin with, we will define three Cartesian unit vectors i, j,
k that are aligned with the x -, y- and z -axes respectively:
i = [1 0 0], j = [0 1 0], k=[0 0 1]
• Therefore any vector aligned with the x-, y- or z -axes can be
defined by a scalar multiple of the unit vectors i, j and k
respectively.
• By employing the rules of vector addition and subtraction, we
can compose a vector r by adding three Cartesian vectors as
follows:
r = ai + bj + ck
• This is equivalent to writing r as: r = [a b c]
which means that the magnitude of r is readily computed as
||r|| = √ (a2 + b2 + c2)
• Any pair of Cartesian vectors such as r and s can be combined
as follows:
r = ai + bj + ck
s = di + ej + fk
r ± s = (a ± d)i + (b ± e)j + (c ± f)k

https://E-next.in
7. How Dot product helps in Back Face Detection?
OR
What is back face detection problem? State and explain how
dot product is used to calculate back face detection.
(pdf pg 54)

https://E-next.in
8. Explain in detail Dot or Scalar product with suitable example.
• We could multiply two vectors r and s by using the product of their
magnitudes: ||r|| · ||s||.
• Although this is a valid operation, it does not get us anywhere
because it ignores the orientation of the vectors.
• Figure 6.7 shows two vectors r and s, such that their tails touch.

• Taking s as the reference vector, which is an arbitrary choice, we


compute the projection of r on s, which takes into account their
relative orientation.
• The length of r on s is ||r|| cos(β).
• We can now multiply the magnitude of s by the projected length of r
:
||s||·||r|| cos(β).
• This scalar product is written s · r = ||s|| · ||r|| cos(β)
• The dot symbol ‘·’ is used to represent scalar multiplication.
• Because of this symbol, the scalar product is often referred to as
the dot
• product.
• Now to compute it, we define two Cartesian vectors r and s,
and proceed to multiply them together using the dot product
definition:
r = ai + bj + ck s = di + ej + fk
therefore,
r · s = (ai + bj + ck) · (di + ej + fk)
= ai · (di + ej + fk) + bj·(di + ej + fk) + ck·(di + ej + fk)
r · s = ad(i · i) + ae(i · j) + af(i · k) + bd(j · i) + be(j · j) + bf(j · k)
+ cd(k · i) + ce(k · j) + cf(k · k)
• Using the definition of the dot product, terms such as (i · i), (j · j)
and
(k · k) = 1, because the angle between i and i, j and j, or k and k is
0◦; and
cos(0◦) = 1. But because the other vector combinations are
separated by 90◦,

https://E-next.in
and cos(90◦) = 0, all remaining terms collapse to zero. Bearing in
mind that
the magnitude of a unit vector is 1, we can write
||s|| · ||r|| cos(β) = ad + be + cf

9. Explain in detail Cross or Vector product with suitable


example.

//INCOMPLETE (pdf – pg 56)

Vector product, which is also called the cross product because of the ‘×’
symbol used in its notation.
It is based on the definition that two vectors r and s can be multiplied
together
to produce a third vector t: r×s=t
where ||t|| = ||r|| · ||s|| sin(β), and β is the angle between r and s.

https://E-next.in
10. State the difference between dot product and cross product
of vectors.
Dot product or scalar product Cross product or vector product
If the product of two vectors is a scalar If the product of two vectors is a vector
quantity, quantity then the product is called vector
the product is called scalar product or dot product or cross product.
product.
The dot product is defined by the relation: The cross product is defined by the
A . B = AB Cos θ relation:
A × B = AB Sin θ
The scalar product obeys commutative law The vector or cross product does not obey
as commutative law
A.B =B.A A×B ≠B×A
If two vectors are perpendicular to each If two vectors are parallel to each other,
other then their scalar product is zero. their vector product is zero.
A.B =0 A×B=0

12. How does Dot product help in Light Intensity calculation?


OR Explain how the dot product is useful in calculating lighting of
an object. (pg53)

https://E-next.in
https://E-next.in
15. Explain 3D translation, 3D Scaling with suitable examples.

https://E-next.in
16. Write a short note on 3D rotation.
• In two dimensions a shape is rotated about a point, whether it be the
origin
or some arbitrary position. In three dimensions an object is rotated
about an
axis, whether it be the x -, y- or z -axis, or some arbitrary axis.
• Using the general 2D-rotation transformation which in 3D can be
visualized as rotating a point P(x, y, z) on a plane parallel with the xy-
plane.
• In algebraic terms this can be written as

which basically rotates a point about the z -axis.


• When rotating about the x -axis, the x -coordinate remains constant
while
the y- and z -coordinates are changed. Algebraically, this is

https://E-next.in
• The above rotations are also known as yaw, pitch and roll.
• The roll, pitch and yaw angles can be defined as follows:
o roll is the angle of rotation about the z -axis
o pitch is the angle of rotation about the x -axis
o yaw is the angle of rotation about the y-axis.
• When these rotation transforms are applied, the vertex is first rotated
about
the z -axis (roll), followed by a rotation about the x -axis (pitch),
followed by a
rotation about the y-axis (yaw).

17. Write a short note on Euler Angles.


• The Euler angles are three angles introduced by Leonhard Euler to
describe the orientation of a rigid body with respect to a fixed
coordinate system.
• They can also represent the orientation of a mobile frame of reference
in physics or the orientation of a general basis in 3-dimensional linear
algebra.
• Any orientation can be achieved by composing three elemental
rotations, i.e. rotations about the axes of a coordinate system. Euler
angles can be defined by three of these rotations.
• They can also be defined by elemental geometry and the geometrical
definition demonstrates that three rotations are always sufficient to
reach any frame.
• Another approach for locating the virtual camera involves Euler angles,
but
we must remember that they suffer from gimbal lock
• However, if the virtual camera is located in world space using Euler
angles, the transform relating world coordinates to camera coordinates
can be derived from the inverse operations.
• Consequently, to rotate through angles –roll, –pitch and –yaw, we use

https://E-next.in
18. Write a short note on 2D transformations.

https://E-next.in
• Transformation means changing some graphics into something else by
applying rules
• Translation
o A translation moves an object to a different position on the
screen.
o You can translate a point in 2D by adding translation coordinate
(tx, ty) to the original coordinate X, Y to get the new coordinate
X′, Y′

• Rotation
o In rotation, we rotate the object at particular angle θ theta from
its origin.
o Considering a point P (X, Y) is located at angle φ from the
horizontal X coordinate with distance r from the origin.
o Let us suppose you want to rotate it at the angle θ. After rotating
it to a new location, you will get a
o new point P’ (X′, Y′).

• Scaling
o To change the size of an object, scaling transformation is used.
In the scaling process, you either expand or compress the
dimensions of the object.
o Scaling can be achieved by multiplying the original coordinates of
the object with the scaling factor to get the desired result.
o Let us assume that the original coordinates are X, Y, the scaling
factors are (SX, SY), and the produced coordinates are X′, Y′.

https://E-next.in
• Reflection
o Reflection is the mirror image of original object. In other words,
we can say that it is a rotation operation with 180°.
o In reflection transformation, the size of the object does not
change.

• Shear

https://E-next.in
19. What is 3D transformation? State and explain scaling and
reflection in 3D.
• Transformations are a fundamental part of the computer graphics.
• Transformations are the movement of the object in Cartesian plane.
• Transformations are used to position objects, to shape objects, to
change viewing positions, and even how something is viewed.
• When transformation takes place on a 3D plane, it is called 3D
transformation.
• Methods for object modelling transformation in 3D are extended from
2D methods by including consideration for the z coordinate.
• 3D Scaling
o You can change the size of an object using scaling
transformation. In the scaling process, you either expand or
compress the dimensions of the object.
o Scaling can be achieved by multiplying the original coordinates of
the object with the scaling factor to get the desired result.

o
• 3D Reflections
o A three-dimensional reflection can be performed relative to a
Selected reflection axis or with respect to a selected reflection
plane.
o The 3D reflection matrices are set up similarly to those for 2D.
o Reflections relative to a given axis equivalent to 180° rotations
about that axis.
o Reflections with respect to a plane are equivalent to 180°
rotations in four dimensional space. The reflection relative to xy,
yz and zx planes are as shown in figure (6).

https://E-next.in
o

https://E-next.in
20. What is transformation? State and explain the concept of
translation in 2D and 3D.
• Transformations are a fundamental part of the computer graphics.
• Transformations are the movement of the object in Cartesian plane.
• Transformations are used to position objects, to shape objects, to
change viewing positions, and even how something is viewed.
• When transformation takes place on a 2D axis, it is called 2D
transformation.
• When transformation takes place on a 3D plane, it is called 3D
transformation.
• 2D Translation
o A translation moves an object to a different position on the
screen. You can translate a point in 2D by adding translation
coordinate (tx, ty) to the original coordinate (X, Y) to get the new
coordinate (X’, Y’).

o
• 3D Translation
o In 3D translation, we transfer the Z coordinate along with the X
and Y coordinates.
o The process for translation in 3D is similar to 2D translation. A
translation moves an object into a different position on the
screen.
o A point can be translated in 3D by adding translation coordinate
(tx,ty,tz) to the original coordinate (X, Y, Z) to get the new
coordinate (X’, Y’, Z’).

https://E-next.in
21. Write a short note on 2D rotation.
• In rotation, we rotate the object at particular angle θ (theta) from
its origin.

• From the following figure, we can see that the point P(X, Y) is located
at angle φ from the horizontal X coordinate with distance r from the
origin.

https://E-next.in
24. Describe cartesian xy plane and explain the concept of
function graph.

• The Cartesian xy-plane

o The Cartesian xy-plane provides a mechanism for translating


pairs of related variables into a graphical format.
o The variables are normally x and y, as used to describe a
function such as y = 3x+2.
o Every value of x has a corresponding value of y, which can be
located on intersecting axes
o The set of points forms a familiar straight line associated with
equations of the form y = mx+c.
o By convention, the axis for the independent variable x is
horizontal, and the dependent variable y is vertical.
o The axes intersect at 90◦ at a point called the origin.
o Measurements to the right and left of the origin are positive
and negative respectively, and measurements above and
below the origin share a similar sign convention
o Any point P on the Cartesian plane is identified by an ordered
pair of numbers (x, y) where x and y are called the Cartesian
coordinates of P.
o Mathematical functions and geometric shapes can then be
represented as lists of coordinates inside a program.

• Function Graphs

o A wide variety of functions, such as y = mx + c (linear), y = ax2


+ bx + c (quadratic), y = ax3 + bx2 + cx + d (cubic), y = a sin(x)
(trigonometric), etc. create familiar graphs that readily identify
the function’s origins.
o Linear functions are straight lines, quadratics are parabolas,
cubics have an ‘s’ shape, and trigonometric functions often have
a wave-like trace.
o Such graphs are used in computer animation to control the
movement of objects, lights and the virtual camera.
o But instead of depicting the relationship between x and y, the
o graphs show the relationship between an activity such as
movement, rotation, size, brightness, colour, etc., with time.

https://E-next.in
o Such a function forms part of the animator’s user interface, and
communicates in a very intuitive manner the brightness of the
light source for every frame of animation. The animator can then
make changes to the function with the aid of interactive software
tools.

https://E-next.in

You might also like