Unit-1 DirectX Pipeline and Programming (E-Next - In)
Unit-1 DirectX Pipeline and Programming (E-Next - In)
Unit-1 DirectX Pipeline and Programming (E-Next - In)
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
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.
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.
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
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
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
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).
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.
• Function Graphs
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