1 / 45

Mathematical fundamentals of 3D computer graphics

Mathematical fundamentals of 3D computer graphics. 1.1 Manipulating three-dimensional structures 1.2 Vectors and computer graphics 1.3 Rays and computer graphics 1.4 Bi-linear Interpolation of polygon properties 1.5 A basic maths engine using SIMD instructions.

robyn
Télécharger la présentation

Mathematical fundamentals of 3D computer graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mathematical fundamentals of 3D computer graphics 1.1 Manipulating three-dimensional structures 1.2 Vectors and computer graphics 1.3 Rays and computer graphics 1.4 Bi-linear Interpolation of polygon properties 1.5 A basic maths engine using SIMD instructions

  2. 1.1 Manipulating three-dimensional structures • This chapter deals with basic three-dimensional transformations and three-dimensional geometry . • In computer graphics the most popular method for representing an object is the polygon mesh model. • A polygon mesh model consists of a structure of vertices, each vertex being a three-dimensional point . • 1.1.1 Three-dimensional geometry in computer graphics-affine transformations • 1.1.2 Transformations for changing coordinate systems

  3. 1.1.1 Three-dimensional geometry in computer graphics-affine transformations • Cartesian coordinate system • Right-handed • Left-handed

  4. Transformation • Translation • Scaling • Rotation

  5. Homogeneous coordinates to • for and scale factor • x = X/w • y = Y/w • z = Z/w • Default w =1 then the matrix representation of a point is

  6. Translation • translation

  7. Scaling • Scaling

  8. Rotation • Rotation • Z axis

  9. Inverse of transformation • T-1, negate Tx, Ty, Tz • S-1, replace Sx, Sy, Szby 1/Sx,1/Sy,1/Sz • R-1, negate the angle of rotation 

  10. Inverse of transformation • These transformation can be multiplied or concatenated together to give a net transformation matrix. For example: • in the product M2M1, the first matrix to be multiplied is M1 • translations are commutative, rotations are not and

  11. Linear transformations examples • Identity

  12. Linear transformations examples • Z-axis rotation

  13. Linear transformations examples • X-scale

  14. Linear transformations examples • Translation

  15. Linear transformations examples • Rotation followed by translation

  16. Linear transformations examples • Translation followed by rotation

  17. Rotating about the object’s reference point • Translate the object to origin • Apply the desired rotation, and • Translate the object back to its original position The net transformation matrix is:

  18. Rotating about the object’s reference point

  19. 1.1.2 Transformations for changing coordinate systems • Coordinate systems • Object coordinate • World coordinate • View coordinate • Transformations • Modeling transformation • Object to world • Viewing transformation • World to view

  20. 1.2 Vectors and computer graphics • Addition of vectors • Length of vectors • Normal vectors and cross-products • Normal vectors and dot products • Vectors associated with normal vector

  21. 1.2.1 Addition of vectors • X = V + W = (x1,x2,x3) = (v1+w1, v2+w2, v3+w3)

  22. 1.2.2 Length of vectors • Length of V • Normalise vector V to produce a unit vector U

  23. 1.2.3 Normal vectors and cross-products • Cross product • i, j and k are the standard unit vectors

  24. 1.2.3 Normal vectors and cross-products • The normal to the polygon is found by taking the cross product of these:

  25. 1.2.3 Normal vectors and cross-products • If the surface is a bi-cubic parametric surface, then the orientation of the normal vector varies continuously over the surface. For a surface defined as Q (u, v) we find: We then define:

  26. 1.2.4 Normal vectors and products • Dot product of vectors • Using the cosine rule ( θis the angle between the vectors )

  27. 1.2.4 Normal vectors and products • We can use the dot product to project a vector onto another vector. If we project any vector W onto V(V is a unit vector), then we have:

  28. 1.2.5 Vectors associated with the normal vector • The light vector L is a vector whose direction is given by the line from the tail of the surface normal to the light source

  29. 1.2.5 Vectors associated with the normal vector • The reflection vector R is given by the direction of the light reflected from the surface due to light incoming along direction L.

  30. 1.2.5 Vectors associated with the normal vector • View vector V that this vector has any arbitrary orientation and we are normally interested in that component of light incoming in direction L that is reflected along V.

  31. 1.2.5 Vectors associated with the normal vector • Consider the construction shown in figure.

  32. 1.3 Rays and computer graphics • Ray geometry – intersections • Intersections – ray – sphere • Intersections – ray – convex polygon • Intersections – ray – box

  33. 1.3.1 Ray geometry – intersections • The most common calculation associated with rays is intersection testing. • The most common technique used to make this more efficient is to enclose objects in the scene in bounding volume – the most convenient being a sphere.

  34. 1.3.2 Intersections – ray – sphere • The intersection between a ray and a sphere is easily calculated. The end points of the ray are (x1,y1,z1), (x2,y2,z2) then parametrise the ray: • A sphere at center (l, m ,n) of radius r is given by: • Substituting for x, y, z gives a quadratic equation in t of the form:

  35. 1.3.2 Intersections – ray – sphere • Solution: • Determinant: • D>0 :二根為前後二交點 • D=0 :相切於一點 • D<0 :沒有交點 • If the intersection point is (xi, yi, zi ) and the centre of the sphere is (l, m, n) then the normal at the intersection point is :

  36. 1.3.3 Intersections – ray – convex polygon • If an object is represented by a set of polygons and is convex then the straightforward approach is to test the ray individually against each polygon. We do this as follow: • Obtain an equation for the plane containing the polygon • Check for an intersection between this plane and the ray • Check that this intersection is contained by the polygon

  37. 1.3.3 Intersections – ray – convex polygon • Example: • 包含polygon的平面:Ax + By + Cz + D = 0 • Ray 的參數式: • The intersection (將參數式代入平面求解)

  38. 1.3.3 Intersections – ray – convex polygon • If t<0. This means that the ray is in the half-space defined by the plane that does not contain the polygon. • If the denominator is equal to zero which means that the line and plane are parallel. In this case the ray origin is either inside or outside the polyhedron.

  39. 1.3.3 Intersections – ray – convex polygon • Test a point for containment by a polygon • Simple but expensive method: • 由此點畫直線連接多邊形各頂點, 若夾角的合為360, 則交點在此polygon內部, 否則此交點在polygon外部 • Haines method: • 依光線行進方向將每一平面分成front-facing, back-facing: • 分母>0:back-facing • 分母<0:front-facing

  40. 1.3.3 Intersections – ray – convex polygon • Haines algorithm {initialize tnear to large negative value tfar to large positive value} if {plane is back-facing} and (t<tfar) then tfar = t if {plane is front-facing} and (t>tnear) then tnear = t if (tnear>tfar) then {exit – ray misses}

  41. 1.3.3 Intersections – ray – convex polygon

  42. 1.3.1 Intersections – ray – box • Treat each pair of parallel planes in turn. • Calculating the distance along the ray to the first plane (tnear) and the distance to the second plane (tfar). • The larger value of tnear and the smaller value of tfar is retained between comparisons. • If the larger value of tnearis greater than smaller value of tfar, the ray cannot intersect the box.

  43. 1.3.1 Intersections – ray – box

  44. 1.4 Bi-linear interpolation of polygon properties • Bi-linear interpolation equations • Final equation (constant value calculated once per scan line)

  45. 1.4 Bi-linear interpolation of polygon properties

More Related