Download presentation

Presentation is loading. Please wait.

Published byShona Robertson Modified over 2 years ago

1
**ppt from Angel, AW, Harvard and MIT Open Courseware, etc.**

v=T(u) Transformations Angel: Chapter 3 ppt from Angel, AW, Harvard and MIT Open Courseware, etc. CSCI 6360/4360

2
**Update Program 4 not due until a week later**

Only term project proposal / design due next week

3
**Term Project 25% of Course Grade**

4
**Term Project 25% of Course Grade**

The term programming project will consist of the design, implementation, documentation, and demonstration of a moderately complex computer graphics software system and will account for 25% of the final grade. The purpose of the project is to provide the student with an opportunity to explore the application of computer graphics in a domain of his or her choosing. It is genuinely intended to provide a platform for creativity, as well as workman like execution. The domain of the project can be in any area: from implementation of a computer graphics algorithm (or its extension) to games to visualization to …. There are many computer graphics student project titles available via the web, so look around, have a go at something that interests you, be creative, and enjoy. The project consists of the elements below.

5
**Term Project Components**

Proposal / design, 10% Milestones, 5% Implementation, 50% Report / documentation, 10% Demonstration, 25%

6
Proposal / design, 10% A two page proposal (12 pt. font, single space, 1” margins) will outline the project and its motivation. Proposals must be approved by the instructor. After submitting the proposal (2/26 12:00 noon or before), preliminary feedback will be given within one day. The feedback will be of the form: ok, ok with revisions/suggestions delineated in the initial feedback, or “we should talk”, in which case arrangements for a conversation will be made such that the revisions can be completed by week’s end. Getting the proposal in early makes a lot of sense. Just talking about ideas over the first couple of weeks makes a lot of sense, too. Remember, the range of possibilities is large, and iteration with the instructor can facilitate development of a proposal that is both within the scope of the class and can be completed in the semester’s time frame.

7
Milestones, 5% Notwithstanding the difficulty in estimating software project time (made an order of magnitude harder by programming in an unfamiliar system), the proposal should include milestones for 4/2 that will include an executable be delivered to the instructor, as detailed in the next section. The milestones must be clear and stated as measureable elements. This will likely require a design and implementation strategy that creates a system that can be developed in stages in which there is some subset of final functionality available at each stage.

8
Implementation, 50% The system must make use of OpenGL for its computer graphics capabilities, and whatever else you would like for any window system and other functionality, e.g., Qt. In class, we will note the wide availability of code examples. By all means make use of them, but by no means take any credit, i.e., carefully document in the code the source of any code you have not written. Failure to do so will result in a grade reduced as a function of the amount of code not cited. The code itself should be reasonably well documented with respect to algorithms, structure, etc., sufficient that the instructor can make sense of it.

9
**Implementation, 50% (cont.)**

At milestone date code and executable will be submitted in the same manner as homework and, as with homework, the assignment will not be accepted after the date on which it is due. Of course, it is possible and reasonable that the functionality described at the milestone will not be achieved. If that is the case, and appropriate effort can be documented, e.g., “tried this that and the other and here is the 1000 lines of code that did not work”, then no deduction in score will be made. This is a tricky one – my hope is that you would propose an ambitious project and we can manage risk appropriately. More in class.

10
**Report / documentation, 10%**

On the night of the first demonstration (4/23) a five page summary of the project is to be turned in. The report should document your efforts and accomplishment in light of the proposal, as well as any difficulties, lessons learned, etc.

11
Demonstration, 25% A 15 minute demonstrations of each project during the last two weeks of class is required. The demonstration should not only show the system’s functionality, but also provide background, motivation, etc., as presented in the proposal and report. Systems that do not execute will receive no credit for this section. Importantly, the demonstration should be engaging and well rehearsed. It is not sufficient to simply address the class offhandedly, work through (say) the menu system, and remember what things do. Such thoughless demonstations will receive 0 credit. This as an opportunity to “show off” not only the functionality of the system you have implemented, but also your skills of professional technical presentation and, well, showmanship (remember the “engaging” criterion).

13
About Relation of mathematic description and computer graphic application Presents an explication of coordinate free approach to geometry of interest in cg That’s coordinate free – surely not for cg Purely abstract, the “robust mathematical foundation” Consider change in frames As implementation change in axes orientations Consider homogenous coordinates Mathematic view that leads to efficient implementation We’ll look at computer graphics applications first

14
Overview Think about “math, transformations, …” in both intuitive/practical-graphics way and mathematical way Transformations Scaling, translation, rotation OpenGL state of “viewing” matrix (time permitting) Geometry 1: Elements of geometry: Scalars, Vectors, Points Geometry 2: Introduce concepts such as dimension and basis Geometry 3: Introduce coordinate systems Used to represent vectors spaces and frames for represent affine spaces Discuss change of frames and bases Introduce homogeneous coordinates Develop mathematical operations among elements in a coordinate-free manner Important because of cg implementation Show OGL use

15
**Recall, Polygon Mesh Representation**

Interactive computer graphics uses polygon representation of objects for efficiency Wireframe shows only the polygons Vertex position for every polygon Shading of polygons used to add “realism” Photorealisism, as well 42, 64, 91 47, 69, 90 environment mapping bump mapping flat shading smooth shading

16
**Polygon Mesh Representation**

Each polygon represented by a set of points Operations on these vertices are at core of interactive cg techniques And, it is the vertices upon which most of the processing in the pipeline is performed Also, E.g., Gouraud, interpolated, shading simply takes illumination values at vertices as inputs Vertex lists … more later 42, 64, 91 47, 69, 90

17
Recall, Coordinate Systems in Viewing Transformations of these coordinate systems at core of graphics pipeline! Coordinate Systems in the Graphics Pipeline OCS – object coordinate system WCS – world coordinate system VCS – viewing coordinate system CCS – clipping coordinate system NDCS - normalized device coordinate system DCS – device coordinate system And images are formed on the image plane

18
**Viewing BTW, frustum Thinking about viewing ….**

In what is displayed on view plane Consider moving the viewpoint and consider moving the object (scene) Object position and/or orientation changed – “Are you or is it moving?!” BTW, frustum Transformations used to create image on screen when an object is viewed Also, OGL viewing based on specification of transformation matrices Specify a world Possibly, transform the world Specify a projection Clip (exclude from image) part of world Specify a viewport into the world

19
**OpenGL The big picture … in small print**

ModelView Matrix Transformation of elements for projection on view plane Projection matrix Clipping Viewport It is points / lines that are sent down the pipeline Rasterization is done at latest possible time For efficiency

20
**Transformations and Coordinate Systems … to Eye/View Coordinate System**

Coordinate Systems in the Graphics Pipeline OCS – object coordinate system WCS – world coordinate system VCS – viewing coordinate system CCS – clipping coordinate system NDCS - normalized device coordinate system DCS – device coordinate system Series of “viewing transformations” transforms a point (its coordinates) from world space to eye space Set these transformation matrices as part of OpenGL programming Each transformation operates on different spaces and coordinates Model – View – Projection – Perspective Divide - Viewport

21
**OpenGL Transformations**

Viewing process has 2 parts: Use model-view matrix to switch vertex reps from object frame in which objects defined to their representation in eye/camera frame – eye at origin Allows use of canonical viewing procedures Type of projection (parallel or perspective) and part of world to image (clipping or view volume) Normalization lets clip against simple cube regardless of projection Delay final projection until end Important for hidden-surface removal to retain depth information as long as possible

22
OpenGL Clip Space In OpenGL clip space, viewing frustum is mapped to a cube that extends from -1 to 1 in x, y, and z Cube is good for efficient clipping algorithms! Called normalization, as in “normalize frustum to unit cube” OpenGL also flips z axis to create a left handed coordinate system during projection Series of transformations are used to create the unit cube

23
**Clipping and Perspective Division**

Scene's objects are clipped against clip space bounding box Eliminates objects (and pieces of objects) not visible in image Efficient clipping algorithms for homogeneous clip space Perspective division divides all by homogeneous coordinates, w (next week) Clip space becomes Normalized Device Coordinate (NDC) space after perspective division

24
**Viewport Transformation**

OpenGL provides function to set up viewport transformation: glViewport(x, y, width, height) Maps NDC space to window (screen) space And we’re done!!!!!!!!! Straightforward: Though need attend to aspect ratio

25
**OpenGL Transformations and Coordinate Systems**

Should feel reasonably comfortable with changes in coordinate spaces through series of transformations Both in practical (OpenGL) and (intuitively) theoretical terms Coordinate spaces: Object World Eye Clip NDC Window Transformations: Model View Projections Perspective Divide Viewport

26
**OpenGL Transformations and Coordinate Systems**

Should feel reasonably comfortable with changes in coordinate spaces through series of transformations Both in practical (OpenGL) and (intuitively) theoretical terms Coordinate spaces: Object World Eye Clip NDC Window Transformations: Model View Projections Perspective Divide Viewport

27
Transformations

28
**Transformations v=T(u)**

“changing something to something else via rules” mathematics: mapping between values in a range set and domain set (function/relation) geometric: translate, rotate, scale, shear,… Transformation: Maps an object into another object In general, a transformation maps every point on an object to another point in the underlying coordinate space Change size, location, orientation of objects without changing underlying model (or primitive drawing commands) Animation, etc. Why are they important to graphics? moving objects on screen / in space mapping from model space to world space to camera space to screen space specifying parent/child relationships … and efficiencies of matrix multiplication in pipeline v=T(u)

29
**Good Transformations for CG**

Line Preserving Because, if not …. P1’ P2’ P1 P2 Line Not Preserved

30
**(S) Linear and Affine Transformations**

Linear transformations Let T: AB, where A and B vector spaces T is linear transformations iff T(a+b) = T(a) + T(b) a, b vector space V T(a) = T(a) is a scalar T(i iai) = iiT(ai) Affine transformations Let T: AB, where A and B affine spaces T is affine transformations iff T is a linear transformations on vectors T maps vectors to vectors and points to points T(P + a) = T(P) + T(a) where P is a point and a is a vector

31
Transformations Will first look at transformations less “mathematically” and revisit matrix operations Will start very simply, ... “refreshing” computational ideas Introduce standard transformations: Scaling Translation Rotation Shear Derive homogeneous coordinate transformation matrices Build arbitrary transformation matrices from simple transformations

32
**Scaling Scale - Changing the size of an object**

Scale object by scaling x and y coordinates of each vertex in object Can have different scale values for scaling x and y: sx, sy So, for all points, x,y , x’ = x * sx, y’ = y * sy

33
**Scaling Example, 1 Below, sx = sy = 2 x’ = x * sx, y’ = y * sy**

For all pts (x,y), x’ = x * 2, y’=y * 2 Where “all” = enough points to illustrate 4,4 x 2 = 2,2 2,2 1,1

34
**Scaling Ex., Matrix Representation**

Below, sx = sy = 2 x’ = x * sx, y’ = y * sy For all pts (x,y), x’ = x * 2, y’=y * 2 Represent points as vectors, transformation as matrix, and multiply Allows many things … efficiency . 4,4 x 2 = 2,2 2,2 1,1

35
Scaling Example, 3 Represent points, P1 and P2, as vectors and scaling values, sx, sy as matrix Then multiply each point by scale matrix… (“over and down”) to transform 4,4 x 2 = 2,2 2,2 1,1

36
BTW, Matrix Things Premultiplying by a row vector is the same as postmultiplying by a column vector Will see both ways in computer graphics Identity matrix That matrix which, when a matrix is multiplied by it, results in the same value of the matrix being multiplied

37
Translation Translate - Change the position of an object (move to new location) Translate object by translating x and y coordinates of each vertex in object Can have different translation values for translating in x and y: tx, ty So, for all points, x, y , x’ = x + tx, y’ = y + ty Same song, second verse … will use matrix operations

38
**Translation Matrix, 1 Again, want x’ = x + tx, y’ = y + ty**

Consider how a matrix (vs. just adding to x, y) might be used to do this: Unlike scaling (x’ = x * sx, y’ = y * sy) , above is just adding, not multiplying Have seen that matrix multiplication is a series of repeated adds and multiplies Also, just seen there is a matrix that, when used in multiplication, returns original values Just need to get original values returned, but with something (tx, ty) added add Tx add Ty How about Tx? How about Ty?

39
**Translation Matrix, 2 Again, want x’ = x + tx, y’ = y + ty**

How about Tx? How about Ty? So, that is what we want! But, what about that extra value in the position vector? No problem, … homogenous coordinates and mathematics

40
**General Form of Transformations**

General representational form of transformations

41
**Homogenous Coordinates, 1**

Add an extra dimension In 2D, use 3 x 3 matrices In 3D, use 4 x 4 matrices Each point has an extra value, w

42
**Homogenous Coordinates, 2**

Most of the time w = 1, and can “ignore” it If we multiply a homogenous coordinate by an affine (line and ratio preserving) matrix, w is unchanged

43
**Homogenous Coordinates, 3**

Divide by w to normalize (homogenize) w= 0, point at infinity (direction) (0, 0, 1) = (0, 0, 2) = … (7, 1, 1) = (14, 2, 2) = … (4, 5, 1) = (8, 10, 2) = … Will see this again, when talk about geometry w = 1 w = 2

44
Translation Matrix We can also express translation using a 4 x 4 matrix T in homogeneous coordinates p’=Tp where T = T(dx, dy, dz) = This form is better for implementation because all affine transformations can be expressed this way and multiple transformations can be concatenated together

45
**Combining Transformations**

Order matters … Matrix multiplication is not commutative 1. Scale, then translate: p’ = T(Sp) = TSp 2. Translate, then scale: p’ = S(Tp) = STp

46
**Order of Transformations**

Note that matrix on the right is the first applied Mathematically, the following are equivalent p’ = ABCp = A(B(Cp)) Note - many references use column matrices to represent points. In terms of column matrices p’T = pTCTBTAT

47
**Affine Transformations**

Line preserving Characteristic of many physically important transformations Rigid body transformations: rotation, translation Scaling, shear Importance in graphics is that we need only transform endpoints of line segments and let implementation draw line segment between the transformed endpoints

48
**Pipeline Implementation “points down the pipeline”**

(some transformation from application program) frame buffer u T(u) transformation rasterizer v T(v) T(v) T(v) v T(u) T(u) u vertices vertices pixels

49
Notation (again) Will be working with both coordinate-free representations of transformations and representations within a particular frame P,Q, R: points in an affine space u, v, w: vectors in an affine space a, b, g: scalars p, q, r: representations of points array of 4 scalars in homogeneous coordinates u, v, w: representations of points

50
**Translation Move (translate, displace) a point to a new location**

Displacement determined by a vector d Three degrees of freedom P’=P+d Although can move a point to a new location in infinite ways, when we move many points there is usually only one way p’ d p object translation: every point displaced by same vector

51
**Rotation (2D), Briefly Consider rotation about the origin by q degrees**

radius stays the same, angle increases by q x = r cos (f + q) y = r sin (f + q) x’=x cos q –y sin q y’ = x sin q + y cos q x = r cos f y = r sin f

52
**Rotation about the z Axis 3d homogenous coordinate representation**

Rotation about z axis in 3 dimensions leaves all points with same z Equivalent to rotation in two dimensions in planes of constant z x’=x cos q – y sin q y’ = x sin q + y cos q z’ =z Or, in homogeneous coordinates p’=Rz(q)p Matrix representation, 3d, homogenous coords: R = Rz(q) = x y z

53
**Rotation about x and y axes (so, just saw rotation about x axis)**

Rotation about z axis (z unchanged) R = Rz(q) = x y z

54
**Rotation about x and y axes (rotation about x axis leaves x unchanged)**

Rotation about z axis (z unchanged) R = Rz(q) = For rotation about x axis, x is unchanged R = Rx(q) = x y z

55
**Rotation about x and y axes (and rotation about y axis leaves y unchanged)**

Rotation about z axis (z unchanged) R = Rz(q) = For rotation about x axis, x is unchanged R = Rx(q) = For rotation about y axis, y is unchanged R = Ry(q) = x y z

56
**Combining Transformations Example – Rotation of Object**

Rotation transformation rotates an (entire) object around the scene’s (x,y,z) origin Usually, when think of “rotating” an object, we mean around its own centerpoint, as in middle figure Not with respect to the scene, as in right To rotate an object about its center, must: 1. Translate object (fixed point) to origin 2. Apply transformation rotation 3. Translate object (fixed point) back to its initial position

57
**Combining Transformations Example – Rotation of Object**

Again, to rotate 1. Move object (fixed point) to origin 2. Rotate 3. Move object (fixed point) back In terms of matrices, can combine separate into single: M = T(pf) R(q) T(-pf)

58
Google Today

59
**OpenGL Example of using Transformation “Directly”**

Solar system (with 1 planet)

60
**Solar System Example: Rotate**

void glRotate{fd}(angle, x, y, z); Multiplies the OpenGL current matrix (more later) by a matrix that rotates an object (or the local coordinate system) in a counterclockwise direction about the ray from the origin through point (x, y, z). The angle parameter specifies the angle of rotation in degrees. E.g., glRotatef(45.0, 0.0, 0.0, 1.0) A rotation of 45 degrees about the z-axis

61
**Solar System Example void display(void)**

#include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> static int year = 0, day = 0; // will use to position and user input int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); // callback functions glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; } void init(void) glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); void display(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glPushMatrix(); glutWireSphere(1.0, 20, 16); // draw sun // glRotatef ((GLfloat) angle, x, y, z); glRotatef ((GLfloat) year, 0.0, 1.0, 0.0); glTranslatef (2.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glutWireSphere(0.2, 10, 8); // draw planet glutSwapBuffers(); }

62
**Solar System Example void keyboard (unsigned char key, int x, int y)**

{ switch (key) { case `d': day = (day + 10) % 360; glutPostRedisplay(); // force call break; case `D': day = (day - 10) % 360; glutPostRedisplay(); case `y': year = (year + 5) % 360; case `Y': year = (year - 5) % 360; default: } void reshape (int w, int h) // callback (called on startup) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);} } void display(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glPushMatrix(); glutWireSphere(1.0, 20, 16); // draw sun glRotatef ((GLfloat) year, 0.0, 1.0, 0.0); glTranslatef (2.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glutWireSphere(0.2, 10, 8); // draw smaller planet glutSwapBuffers();

63
**Another Transformation: Scaling**

Expand or contract along each axis (fixed point of origin) x’=sxx y’=syx z’=szx p’=Sp S = S(sx, sy, sz) =

64
**Another Transformation: Reflection**

Corresponds to negative scale factors sx = -1 sy = 1 original sx = -1 sy = -1 sx = 1 sy = -1

65
**Another Transformation: Shear**

Equivalent to pulling faces in opposite directions Consider simple shear along x axis x’ = x + y cot q y’ = y z’ = z H(q) =

66
Inverses … are easy Although could compute inverse matrices by general formulas, we can use simple geometric observations Translation: T-1(dx, dy, dz) = T(-dx, -dy, -dz) Rotation: R -1(q) = R(-q) Holds for any rotation matrix Note that since cos(-q) = cos(q) and sin(-q)=-sin(q) R -1(q) = R T(q) Scaling: S-1(sx, sy, sz) = S(1/sx, 1/sy, 1/sz)

67
**Concatenation and Efficiency**

This is a big idea! …

68
**Concatenation and Efficiency**

This is a big idea! … Recall, example of rotation of an object We can form arbitrary affine transformation matrices by multiplying together rotation, translation, and scaling matrices Because the same transformation is applied to many vertices, cost of forming a matrix M=ABCD is not significant compared to the cost of computing Mp for many vertices p The difficult part is how to form a desired transformation from the specifications in the application

69
(S) Instancing In modeling, we often start with a simple object centered at the origin, oriented with the axis, and at a standard size We apply an instance transformation to its vertices to: Scale Orient Locate

70
**(S) General Rotation About Origin**

A rotation by q about an arbitrary axis can be decomposed into the concatenation of rotations about the x, y, and z axes y R(q) = Rz(qz) Ry(qy) Rx(qx) v qx qy qz are called the Euler angles q x z Note that rotations do not commute Can use rotations in another order but with different angles

71
**OpenGL Geometry Transformation**

Finally, … we have the details of the several transformations in OpenGL viewing To summarize …

72
**OpenGL Geometry Transformation**

Scenes, Actors, Cameras … yet one more analogy Analogy to classical theatre or photography Virtual world is called a scene Call objects in scene actors Camera specifies view position and view parameters (focal length, image size, etc.) Use 3D affine transformations to position and move actors and cameras in scene

73
**Recall, Coordinate Systems in Viewing**

Coordinate Systems in the Graphics Pipeline OCS – object coordinate system WCS – world coordinate system VCS – viewing coordinate system CCS – clipping coordinate system NDCS - normalized device coordinate system DCS – device coordinate system And images are formed on the image plane

74
**World, Object, Camera Frames**

Use the global world coordinates T to place actors and cameras within the scene Define points (vertices) of objects in some convenient local object coordinates T Define eye coordinates T for the camera There could be more than one camera in the scene

75
**OpenGL Coordinate Spaces**

global world coordinates local object coordinates T eye coordinates T These coordinate spaces are connected by OpenGL transformations

76
**Modeling, Viewing, and Projection Transformations**

The modeling transformation orients objects within the world space

77
**Modeling, Viewing, and Projection Transformations**

The viewing transformation maps points from world space into eye space

78
**Modeling, Viewing, and Projection Transformations**

The projection transformation maps the viewing frustum to clip space, a cube that extends from -1 to 1 in x, y, and z

79
**OpenGL Coordinate Spaces “view of the scene” – shows perspective divide and viewport transformation**

80
**OpenGL Coordinate Spaces In conclusion**

Why multiple coordinate spaces? Normalization allows for a single pipeline for both perspective and orthogonal viewing Stay in four dimensional homogeneous coordinates as long as possible to retain three-dimensional information needed for hidden-surface removal and shading Simplify clipping

82
Geometry

83
**Geometry: Basic Elements**

Geometry is the study of relationships among objects in an n-dimensional space In cg, interested in objects that exist in three dimensions Want minimum set of primitives from which can build more sophisticated objects Will need three basic elements: Scalars, Vectors, Points Coordinate-Free Geometry – important for cg “Simple geometry” - Cartesian approach Points were at locations in space p=(x,y,z) Derived results by algebraic manipulations involving these coordinates This approach was nonphysical Physically, points exist regardless of location of an arbitrary coordinate system Most geometric results are independent of the coordinate system Example from Euclidean geometry: two triangles are identical if two corresponding sides and the angle between them are identical

84
**Vector, Affine, and Euclidean Spaces**

Different “spaces” Vector space Contains 2 distinct entities: vectors and scalars Supports 2 operations: addition and multiplication Scalar-vector multiplication and vector-vector addition Affine space Extension of vector space Supports Vector-point addition that produces a new point Point-point subtraction that produces a vector Euclidean space Extension of vector space that adds a measure of size or distance

85
**(Review) Geometry 1: Basic Geometric Elements**

Scalar a, b, d, e Magnitude (e.g. real numbers) Vector u, v, w, x Direction Magnitude No Position Point P, Q, R, X Position No Direction No Magnitude

86
**(Review) Geometry 1: Scalars**

Scalars can be defined as members of sets which can be combined by two operations (addition and multiplication) obeying some fundamental axioms (associativity, commutivity, inverses) Examples include the real and complex number systems under the ordinary rules with which we are familiar Scalars alone have no geometric properties Operations (what you’d expect): Addition: a+b Additive identity: zero Additive inverse: - b Subtraction defined in terms of additive inverse Multiplication: d * j Multiplicative identity: 1 Multiplicative inverse: 1/ d Division defined in terms of multiplicative inverse

87
**(Review) Geometry 1: Vectors**

Physical definition A vector is a quantity with two attributes Direction Magnitude Examples include Force Velocity Directed line segments Most important example for graphics Can map to other types v

88
**(Review) Geometry 1: Vector Operations, 1**

Every vector has an inverse Same magnitude but points in opposite direction Every vector can be multiplied by a scalar There is a zero vector Zero magnitude, undefined orientation The sum of any two vectors is a vector Use head-to-tail axiom v w v v -v u

89
**(Review) Geometry 1: Vector Operations, 2**

Dot Product Cross Product Addition q u v v u u + v q v u Produces vector w orthogonal to u and v. u · v = | u | | v | cos q Magnitude (produces scalar) A2 = | u |2 + | v |2 w = u x v | w | = | u | | v | sin q (produces vector)

90
**(Review) Geometry 1: Linear Vector Spaces**

Mathematical system for manipulating vectors Recall, Scalar a, b, d, e Magnitude (e.g. real numbers) Vector u, v, w, x Direction Magnitude No Position Operations: Scalar-vector multiplication u=v Vector-vector addition: w=u+v Expressions such as v=u+2w-3r make sense in a vector space

91
**(Review) Geometry 1: Vectors Lack Position**

These vectors are identical Same length and magnitude Vectors spaces insufficient for geometry Need points

92
**(Review) Geometry 1: Points**

Location in space Operations allowed between points and vectors Point-point subtraction yields a vector Addition not meaningful Equivalent to point-vector addition v = P - Q P = v + Q

93
**Geometry 1: Affine Spaces**

Turns out affine spaces are important in cg, because preserves lines And, bottom line, we’re hustling points down a pipeline for efficiency Point + a vector space Operations: Vector-vector addition Scalar-vector multiplication Point-vector addition Scalar-scalar operations For any point, define 1 • P = P 0 • P = 0 (zero vector) P1’ P2’ P1 P2 Line Not Preserved

94
**(Review) Geometry 1: Lines**

Consider all points of the form P(a)=P0 + a d Set of all points that pass through P0 in the direction of the vector d See figure Parametric form of line More robust and general than other forms Extends to curves and surfaces Two-dimensional forms Explicit: y = mx +b Implicit: ax + by +c =0 Parametric: x(a) = ax0 + (1-a)x1 y(a) = ay0 + (1-a)y1

95
**(Review) Geometry 1: Rays and Line Segments**

If a >= 0, then P(a) is the ray leaving P0 in the direction d If we use two points to define v, then P( a) = Q + a (R-Q)=Q+av =aR + (1-a)Q For 0<=a<=1 we get all the points on the line segment joining R and Q

96
**(Review) Geometry 1: Convexity**

An object is convex iff for any two points in the object all points on the line segment between these points are also in the object Saw this earlier in OpenGL polygon description P P Q Q not convex convex

97
**(Review Supplementary) Geometry 1: Affine Sums & Convex Hull**

Consider the “sum” P=a1P1+a2P2+…..+anPn Can show by induction that this sum makes sense iff a1+a2+…..an=1 in which case we have the affine sum of the points P1,P2,…..Pn If, in addition, ai>=0, we have the convex hull of P1,P2,…..Pn Convex hull Smallest convex object containing P1,P2,…..Pn Formed by “shrink wrapping” points

98
**(Review) Geometry 1: Planes**

A plane can be defined by: 1. a point and two vectors 2. three points P v Q R u R 1. P(a,b)=R+au+bv 2. P(a,b)=R+a(Q-R)+b(P-Q)

99
**(Review) Geometry 1: Normals**

Every plane has a vector, n, normal (perpendicular, orthogonal) to it From point-two vector form P(a,b)=R+au+bv, Know we can use the cross product to find n = u v and the equivalent form (P(a)-P) n=0 u v P

100
**(Review) Geometry 1: Operations: Scalars & Vectors**

Multiplication of vector by scalar: Produces vector u v = a u |a u | = a | u |

101
**(Review) Geometry 1: Operations: Points & Vectors**

Affine Addition: Point + Vector = Point Q v P Q = P + v Related to point subtraction.

102
**(Review supplementary) Geometry 1: Lines in Affine Space**

. P Q v Q = P + v R R = P + a v 1 a 0 R’ Line segment from P to Q defined when: 0 £ a £ 1 R’ = P + a v - ¥ < a < ¥ Affine Sum/Combination R= P + a (Q - P) = a Q + (1- a) P = a1 P + a2 Q where a1 +a2 =1

103
**(Review Supplementary) Geometry 1: Planes in Affine Space**

. Planes are defined uniquely by three points: P, Q, R P Q R u v T( b) S(a) S(a) = P + a v T(b) = P + b u W(a, b, l) = S - l (T - S) = P + a v - l (b u - a v) W (a, b, l) = P + a ( 1 + l ) v - l b u W = P + d v + c u W(l) u = Q - P v = R - P

104
**Geometry 2: Basis, Coordinate Systems**

105
**Geometry 2: Basis, Coordinate Systems**

Will look at things such as dimension and basis Concepts familiar, mathematic treatment Also, coordinate systems for representing vectors spaces and frames for representing affine spaces Discuss change of frames and bases Mathematical elements of “transformations” we just saw in some detail Introduce homogeneous coordinates from another perspective Important both for mathematical foundation and practical application, e.g., concatenation of matrices for transformation

106
**Geometry 2: Linear Independence and Dimension**

A set of vectors v1, v2, …, vn is linearly independent if If a set of vectors is linearly independent, cannot represent one in terms of others If a set of vectors is linearly dependent, at least one can be written in terms of others a1v1+a2v2+.. anvn=0 iff a1=a2=…=0 In a vector space, the maximum number of linearly independent vectors is fixed and is called the dimension of the space And it can be any number, not just 2 or 3 or 4 or … n In an n-dimensional space, any set of n linearly independent vectors form a basis for the space Again, no need to correspond to anything physical Given a basis v1, v2,…., vn, any vector v can be written as v=a1v1+ a2v2 +….+anvn where the {ai} are unique

107
**Geometry 2: Representation**

Can work with geometric entities without using any frame of reference, such as a coordinate system That is, one can work with points, vectors, etc. independent of any (real, physical) representation “Just abstract, geometric, mathematic, … entities” Need a frame of reference to relate points and objects to our physical world For example, where is a point? Can’t answer without a reference system Are familiar with World coordinates Camera coordinates

108
**Geometry 3: Coordinate Systems, 1**

Consider a basis v1, v2,…., vn (any set of n linearly independent vectors) With a vector written as v=a1v1+ a2v2 +….+anvn Then the list of scalars {a1, a2, …. an} is the representation of v with respect to the given basis Can write the representation as a row or column array of scalars Example next slide a=[a1 a2 …. an]T=

109
**Geometry 3: Coordinate Systems, 2**

Consider a basis v1, v2,…., vn - (any set of n linearly independent vectors) A vector is written v=a1v1+ a2v2 +….+anvn List of scalars {a1, a2, …. an} is the representation of v with respect to the given basis Can write the representation as a row or column array of scalars Example: vector v = 2v1+3v2-4v3 a = [2 3 –4]T is representation is with respect to a particular basis For example, in OpenGL we start by representing vectors using the object basis but later system needs a representation in terms of the camera or eye basis So, clearly, will be working with multiple bases a=[a1 a2 …. an]T=

110
**Geometry 3: Coordinate Systems**

Consider the two sets of vectors represented graphically below They can be considered to be two bases, i.e., sets of four vectors Both can be appropriate representations There is no particular reason why a bases should correspond (or almost correspond) to something physical In particular, vectors have no fixed location v v

111
Geometry 3: Frames But, a coordinate system (alone) is insufficient to represent points If we work in an affine space (as we do in cg) can add a single point, the origin, to the basis vectors to form a frame Frame determined by (P0, v1, v2, v3) i.e., a point + vectors (of a coordinate system) Within this frame, recall, every vector can be written as v=a1v1+ a2v2 +….+anvn And every point (Pi) can be written as P = P0 + b1v1+ b2v2 +….+bnvn … (cont.) P0 v1 v2 v3

112
**Geometry 3: Frames & Homogeneous Coordinates**

Again, within this frame, every vector can be written as v=a1v1+ a2v2 +….+anvn Again, every point (Pi) can be written as P = P0 + b1v1+ b2v2 +….+bnvn Now, If we define 0•P = 0 and 1•P =P then we can write (by algebraic rewrite) v=a1v1+ a2v2 +a3v3 = [a1 a2 a3 0 ] [v1 v2 v3 P0] T P = P0 + b1v1+ b2v2 +b3v3= [b1 b2 b3 1 ] [v1 v2 v3 P0] T Thus, we obtain the four-dimensional homogeneous coordinate representation v = [a1 a2 a3 0 ] T p = [b1 b2 b3 1 ] T … (cont.) P0 v1 v2 v3

113
**Geometry 3: Homogeneous Coordinates**

. Again, thus we obtain the four-dimensional homogeneous coordinate representation v = [a1 a2 a3 0 ] T p = [b1 b2 b3 1 ] T The homogeneous coordinates form for a three dimensional point [x y z] is given as p =[x’ y’ z’ w] T =[wx wy wz w] T We return to a three dimensional point (for w0) by xx’/w yy’/w zz’/w If w=0, the representation is that of a vector Note that homogeneous coordinates replace points in three dimensions by lines through the origin in four dimensions For w=1, the representation of a point is [x y z 1]

114
**Geometry 3: Homogeneous Coordinates and CG**

Homogeneous coordinates are key to all computer graphics systems All standard transformations (rotation, translation, scaling) can be implemented with matrix multiplications using 4 x 4 matrices As noted earlier Hardware pipeline works with 4 dimensional representations For orthographic viewing, we can maintain w=0 for vectors and w=1 for points For perspective we need a perspective division Next time

115
**Geometry 3: Change of Coordinate Systems**

This is it … mathematic equivalence … Consider two representations of the same vector with respect to two different bases. The representations are: Representing second basis in terms of first Each of the basis vectors, u1,u2, u3, below, are vectors that can be represented in terms of first basis Coefficients, g, of bases form a matrix (next slide) … v a=[a1 a2 a3 ] b=[b1 b2 b3] Where (rewritten), v=a1v1+ a2v2 +a3v3 = [a1 a2 a3] [v1 v2 v3] T =b1u1+ b2u2 +b3u3 = [b1 b2 b3] [u1 u2 u3] T u1 = g11v1+g12v2+g13v3 u2 = g21v1+g22v2+g23v3 u3 = g31v1+g32v2+g33v3

116
**G 3: Change of Coord. System - Matrix Form**

The coefficients of bases define a 3 x 3 matrix and the bases can be related by v M = a=MTb

117
**Geometry 3: Change of Frames**

So, we can apply a similar process in homogeneous coordinates to the representations of both points and vectors Any point or vector can be represented in either frame! E.g., can represent Q0, u1, u2, u3 in terms of P0, v1, v2, v3 P0 v1 v2 v3 Q0 u1 u2 u3 Consider two frames: (P0, v1, v2, v3) (Q0, u1, u2, u3)

118
**G3: Representing One Frame in Terms of Other**

So, can extending what we did with change of bases: u1 = g11v1+g12v2+g13v3 u2 = g21v1+g22v2+g23v3 u3 = g31v1+g32v2+g33v3 Q0 = g41v1+g42v2+g43v3 +g44P0 By defining a 4 x 4 matrix: M = ú û ù ê ë é 1 g 43 42 41 33 32 31 23 22 21 13 12 11

119
**G 3: Working with Representations**

So, this has shown: Within the two frames any point or vector has a representation of the same form a=[a1 a2 a3 a4 ] in the first frame b=[b1 b2 b3 b4 ] in the second frame where a4 = b4 = 1 for points and a4 = b4 = 0 for vectors and: The matrix M is 4 x 4 and specifies an affine transformation in homogeneous coordinates a=MTb

120
**Geometry 3: Affine Transformations Conclusion**

Every linear transformation is equivalent to a change in frames Every affine transformation preserves lines However, an affine transformation has only 12 degrees of freedom because 4 of the elements in the matrix are fixed and are a subset of all possible 4 x 4 linear transformations

121
**OGL: World and Camera Frames**

When we work with representations, we work with n-tuples or arrays of scalars Changes in frame are then defined by 4 x 4 matrices And this is what we saw coming to this the other way around In OpenGL, base frame that we start with is the world frame Eventually, we represent entities in the camera frame by changing the world representation using the model-view matrix Initially, these frames are the same (M=I)

122
**OGL: World and Camera Frames Conclusion (of everything)**

Again, in OpenGL, base frame that we start with is the world frame And, again, eventually, we represent entities in the camera frame by changing the world representation using the model-view matrix

123
End .

Similar presentations

OK

1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,

1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google