Presentation is loading. Please wait.

Presentation is loading. Please wait.

3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.

Similar presentations


Presentation on theme: "3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix."— Presentation transcript:

1 3D Ojbects: Transformations and Modeling

2 Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix. Matrix operations: addition, scalar multiplication, multiplication (nxm can be multiplied by an mxr to produce an nxr), transpose Examples

3 Matrix Multiplication When multiplying matrices, the elements of the rows in the first matrix are multiplied with corresponding columns in the second matrix. For two matrices (where necessarily the number of columns in A equals the number of rows in B equals m) the matrix product AB is defined by where C ij =a i1 b 1j + a i2 b 2j +…+ a im b mj

4 Matrix Multiplication - example Wolfram.com

5 Matrix Multiplication - properties Associative, distributive, not necessarily commutative Square matrices may have inverses to give an identity matrix; determinants Recall that the cross-product gives a vector that is perpendicular to both

6 Transformations Kinds of transformations: translation, scaling, rotating May have combinations: order is important Will start by looking at pixel by pixel movement: where does a particular pixel go Each transformation will be a matrix that is 4x4 and the pixel will be a 4x1 matrix (vector) The pixel will be represented by [x y z 1] T homogeneous coordinates – can divide by last coordinate if not 1 Can multiply matrices together to get the complete transformation: (RTSR 1 )v

7 Translations What matrix would be needed to translate? Start with a 3x4: remember you just want to adjust the x-coordinate by an increment Same with y and z w-coordinate want to leave alone- so fill in the last line See if you can derive the 4x4 matrix

8 Scaling Try same system with scaling: want to multiply each of the coordinates by a quantity See if you can derive the 4x matrix What happens if you want to scale with respect to the object’s coordinate system? Translate to the origin, scale and then translate back.

9 Rotations around the axes Consider positive angles to be towards the positive y-axis; in Processing this will be clockwise and in Virtools it will be counterclockwise Consider rotation with respect to one of the world coordinate axes Will get 3 possibilities

10 Combinations of transformations Have translations, scaling, rotations Can multiply all the transformations together to get a single 4x4 transformation matrix: the order of the multiplications is extremely important; operations are performed in order from right to left Note that inverses of translations are the inverse matrices, as are scalars and rotations (in the opposite direction)

11 Transformations in Processing The push() and pop() functions will preserve these matrices

12 Projections 3D worlds are projected on a 2D computer screen If the objects are to be projected with no change in size (near and far objects of the same size will have the same projections) it is called a parallel or orthographic projection- the projection lines are parallel to the axes If the projection plane is z=0 then have If have the projection plane z=d then

13 Perspective Projections If want a perspective projection then the size of objects will change Viewpoint converges at the eye of the person, plane can be at z=d Then the z distance should be d and the x and y distances should be proportional to (multiplied by) the ratio of d/z (look at similar triangles) This presents a problem for the 4x4 matrix since the form only allows linear combinations of x,y,z This is where the homogeneous coordinates come in: recall that if the w coordinate is not 1 and is not 0, then divide all the coordinates by w to normalize

14 Perspective Matrices Perspective projections are a reason for homogeneous coordinates Try the multiplication to see that it works- the new point will be [x*d/z, y*d/z, d,1] T

15 Building and Displaying Objects Points, line segments, planes, planar patches, convex polygons: all specified through points 3D objects built from these primitives: even curved surfaces and lines Need to store these objects efficiently (descriptions that are not pixel by pixel) Need to render these objects every frame: fast algorithms that are accurate and have the right level of detail- scan conversion decides which pixels to render

16 Line Segments Parametric form for line segment from P 0 to P 1 : L(t)=(1 – t) P 0 + tP 1 where

17 Planes Plane is determined uniquely by 3 non linear points- equivalently 2 vectors Equation for a plane is Ax+By+Cz+D=0 where the constants are not all 0 (A,B,C) are the components of a normal vector Can start with 3 points, form two vectors, find the normal vector (calculate the cross product) and then use one of the points to solve for D.

18 Spheres Need the center and a radius; if radius at origin then have r 2 = x 2 + y 2 + z 2 Could go around the edge of a circle with x and y and solve for z: computationally expensive because involve lots of multiplications and square roots- these cost more than additions and subtractions Algorithm to make this more efficient

19 Convex Polygons Convex polygons: line segments joining points of the polygon are within the polygon If have more than 3 points may not have a unique polygon Safe thing is to have convex polygons triangulated Polygons defined by meshes: order of points is important because it defines the normal: counterclockwise rule (wrap hand in order of points and then the thumb points toward the normal) Data storage of triangles: list of vertices, indices for faces

20 Level of Detail If objects are far away then there is no need for them to have thousands of rectangles or intricate lighting Objects may have different models depending on how close the camera is to the object: for the farthest away there might only be one face with a color or blurry texture In Virtools can specify LOD

21 Scene Hierarchy or Scene Graphs Have levels and parent/child relationships At the very top is the Universe (called Level in Virtools) Hierarchy gives rise to dependent coordinate systems and types of movement where children tag along with the parent


Download ppt "3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix."

Similar presentations


Ads by Google