Game programming QnA, Assignments of Game Theory

Question and answers of game programming subject.

Typology: Assignments

2021/2022

Available from 11/14/2022

n-k-28
n-k-28 🇮🇳

1 document

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Game programming QnA and more Assignments Game Theory in PDF only on Docsity!

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.

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 = √(Δx^2 +Δy^2 )
  • 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 =√(Δx^2 +Δy^2 + Δz^2 )

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 (x^2 + y^2 + z^2 ). o For example, the point P(4, 5,6) creates a position vector p relative to the origin: o p =[4 5 6] ||p|| = (4^2 + 5^2 + 6^2 ) = 20.
  • Unit Vector o By definition, a unit vector has a magnitude of 1 i.e. i = [ 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|| = (x^2 + y^2 + z^2 ) 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|| = (a^2 + b^2 + c^2 )
  • 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

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)

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.

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 quantity, the product is called scalar product or dot product. If the product of two vectors is a vector quantity then the product is called vector product or cross product. The dot product is defined by the relation: A. B = AB Cos θ The cross product is defined by the relation: A × B = AB Sin θ The scalar product obeys commutative law as A.B = B.A The vector or cross product does not obey commutative law A×BB×A If two vectors are perpendicular to each other then their scalar product is zero. A.B = 0 If two vectors are parallel to each other, their vector product is zero. 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 )

15. Explain 3D translation, 3D Scaling with suitable examples.

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

18. Write a short note on 2D transformations.

  • 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′.

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 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).

o

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. -

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 = ax
  • 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.