Create Presentation
Download Presentation

Download Presentation

Geometric Objects and Transformations

Download Presentation
## Geometric Objects and Transformations

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**Geometric Objects and Transformations**Coordinate systems and frames Working with representation Object transformation Suriyong L.**Introduction**• Mathematical of Object • Euclidean vector spaces • Vector space with measure of size • Independent of coordinate system • Parametric form system Suriyong L.**Scalars, Points, and Vectors**• Geometric object description in space • By length, angle • With 3 fundamental types scalars, points and vector Suriyong L.**The geometric View**• Point : a location in the space • Mathematical for point • Neither a size nor shape • Properties • location • What for : • Specify an object Suriyong L.**Scalars**• Quantity of object or relation objects • Ex. Distance between object • Specify with real / complex number • Useful rule for scalar • communitivity and Associativity in multiplicity, additivity • Ex. a+b = b+a, (a+b)+c = a+(b+c) Suriyong L.**Directed line segment that connects points**Identical vectors Vector • Quantity with direction and magnitude ex. velocity, force • Does not have a fixed position in space • Synonymously to line segment • Computer graphics often connect points with directed line segment • Line segment: a segment of line which has both magnitude and direction Suriyong L.**Parallel line segments**Addition of line segments Inverse vectors Vector properties • Its lengths changed by real number • B = 2A • B is double in size to vector A with the same direction • Vector combining: (addition) • Use head to tail combining, the result is the sum of the vector • Any vector in space is able to do addition, independent of its location • Scalar-vector addition make sense: ex. A + 2B – 3C • Inverse vector: • The vector that has opposite direction to the original vector Suriyong L.**Point-vector addition**Vector operation • Scalar multiplying • Result change in length (magnitude) • Point-vector addition • Result change in displacement to the new point position • Point-point subtraction • Result is a vector between 2 points • Note: Some expression involving scalars, vectors and points make sense ex. P+3v, or P-2Q+3v while P+3Q-v do not Suriyong L.**Object and coordinate system**Coordinate-free geometry • For graphics system let the object relate to each other but independent of coordinate system • Let object relate to an arbitrary location and orientation of the original axis Object without coordinate system Suriyong L.**The mathematical view: Vector and Affine Spaces**• Scalar operation • Addition , multiplication • If operation obey closure, associativity, commutivity and inverse properties, the element form a scalar field • Ex. field . Real number, complex number, rational function Suriyong L.**Vector space**• 2 distinct type of entities in vector space • Scalar and vector • Scalar-vector multiplication • Vector and vector • Vector – vector addition • Euclidean space • Extension of vector space • Add a measure of size or distance to define object • Ex. Length of line segment Suriyong L.**Affine space (space of transformation)**• Extension of vector space • Include point to vector space • Have vector-point addition and point-point operation Suriyong L.**Computer Science View**• Prefer to see object as abstract data type (ADT) • Operations and data are defined independently • Fundamental to modern computer science • Like C++ language features : class and overloading vector u,v; point p,q; scalar a, b; Computational point of view declaration (Independent of data type declaration) q = p+a*v; Operation that independent of data type Suriyong L.**Geometric ADT**• Learn how to perform geometric operation and forming geometric object • Let Greek letter a, b, g,... : scalars Upper-case letter P, Q, R,… : points Bold lower-case letters u, v, w,… : vector Suriyong L.**Point-point subtraction**Use of the head-to-tail rule (a) For vectors, (b)For points • The operation of vector-scalar multiplication • Subtraction of two points, P and Q -> vectorv • Add vector with point get point • Vector-vector operation can be in point form Suriyong L.**Lines**• General term definition • Called parametric form of line • Point generating by varying alpha • Line is infinity in length • One we see just line segment Parametric line equation Line in an affine space Suriyong L.**Affine sum**If P is a point on line P=Q+av v = R – Q; Thus P = Q + a(R-Q) = aR + (1-a)Q Let a = a1 and (1-a) = a2 Thus a1 + a2 = 1 Then P=a1R+a2Q Points on line can be found between point Q and P(a) Affine line addition Suriyong L.**Line segment that connects two points**Convexity • Convex object • Any point that lying on line segment connect any two points in the object also in the object • Affine sum definition Objects defined by n points P1, P2,…,Pn. Consider the form When Suriyong L.**Convexity**• An object is convexiff for any two points in the object all points on the line segment between these points are also in the object P P Q Q not convex convex Suriyong L.**Convex hull**Convex hull The set of points formed by the affine sum of n points, under the additional restriction is called the convex hull of the set of points convex hull includes all line segments connecting pairs of points i[P1,P2,…,Pn] The notion of convexity is extreamly important in the design of curves and surfaces; Suriyong L.**Dot product and projection**Dot and Cross product • Dot (inner product) • u.v: result is magnitude of 2 vectors • If u.v = 0, u and v are orthogonal vector • Unit product is Suriyong L.**Cross product**Cross product • Result is vector • Forming from right hand coordinate system Note:right-handed coordinate system u points in the direction of the thumb v points in the direction of the index finger n points in the direction of the middle finger Suriyong L.**Plane**• Infinite flat area • Direct extension of parametric line • Define with 3 non-co-linear points • Suppose P, Q and R are points in plane • The plane equation and Suriyong L.**General plane equation**The plane can have vector(normal vector) formed from u and v Let n :plane vector Thus Suriyong L.**Curves in three dimension**Surfaces in three dimensions Volumetric objects 3D primitives Object are not lying on plane Suriyong L.**2 problems when incorporate in 3D**• Complex mathematic • Not all object that has 3D efficient implementation • Approximated method may be used • 3 features characteristic to describe object • Hollow • Vertices • Flat convex polygon composition Suriyong L.**Coordinate system and frame**• Represents Vector in 3D space with 3 basis vector thus Vector derived from three basis vectors Suriyong L.**Coordinate system (a) with vector emerging from a common**point, (b) with vector moved A Dangerous representation of vector Point and vector representation in affine space • It is not enough to use only vector to represent point in space • Frame: fix point (origin) and basis vector • Vector: represent with 3 basis • Point: fix point and 3 basis Suriyong L.**Representations and N-tuples**• Any vector v representation Where • In column matrix form • Known as Euclidean : Suriyong L.**Coordinate System Changing**World /User frame Camera frame • Done by MODELVIEW matrix • Use 2 basis set of vector and • Representation of by Let and represent matrix from to Suriyong L.**Let**Equivalent to Where Assume : the representation of with respect to or Where Then using our representation of the second basis in terms of the first, we find that Thus The matrix (MT)-1 takes us from a to b: We can transfer coefficient matrix from one to the other Suriyong L.**Translation of a basis**Rotation and scaling of a basis • This changing let us to work with different coordinate system but origin unchanged • Able to use them to represent rotation and scaling but not translation 2 examples 2 different frames Suriyong L.**Example:**Suriyong L.**The matrix that converts a representation in , and to one in**which the basis vector areand is In the new system, the representation of w is That is Suriyong L.**Homogeneous Coordinate**3 basis vector is not enough to make point and vector different For any point: In the frame specified by (v1, v2, v3, P0), any point P can be written uniquely as The we can express this relation formally, using a matrix product, as The yellow matrix called homogeneous-coordinate representationof point P Suriyong L.**In the same frame, any vector w can be written**wcan be represented by the column matrix If and ,can be expressed as Suriyong L.**Can be written in the form**M : the matrix representation of the change of frames. Suppose a and b are the homogeneous-coordinate representations, then Hence, Suriyong L.**When we work with representations, as is usually the case,**we are interested in , which is of the form Only 12 coefficients • Advantage of using homogeneous representation • use 4D matrix instead of 3D matrix • less calculation • modern hardware support the representation • parallelism for high speed calculation Suriyong L.**Example**Suriyong L.**Suppose move the point to (1, 2, 3, 1)**with displacement vector And move from point P0 to Q0 then The matrix becomes Its inverse is We can move back and forth between representation Thus to Suriyong L.**The origin in the new system is represented as**Original vector is transformed to <- b= (MT)-1a Suriyong L.**Working with Representation**• Represent object from a frame to another such as world frame to camera frame • Form of representation a = Cb ; a, b object in two representation frame • Object: • 3 vector, u, v, n, and 1 new frame origin, p -> (u, v, n, p) • 4 entities -> 4-tuples -> R4 • The solution is inverse matrix form of C, let’s say D D = C-1 Suriyong L.**Frames in OpenGL**• 2 frames: • Camera: regard as fix • World: • The model-view matrix position related to camera • Convert homogeneous coordinates representation of object to camera frame • OpenGL provided matrix stack for store model view matrices or frames • By default camera and world have the same origin • If moving world frame distance d from camera the model-view matrix would be Suriyong L.**Camera and world frames**Suriyong L.**Suppose camera at point (1, 0, 1, 1)**• World frame center point of camera • Representation of world frame for camera • Camera orientation: up or down • Forming orthogonal product for determining v let’s say u Camera at (1,0,1) pointing toward the origin Suriyong L.**The model view matrix M**Result: Original origin is 1 unit in the n direction from the origin in the camera frame which is the point (0, 0, 1, 1) OpenGL model view matrix OpenGL set a model-view matrix by send an array of 16 elements to glLoadMatrix We use this for transformation like rotation, translation and scales etc. Suriyong L.**One frame of cube animation**Modeling a Color Cube • A number of distinct task that we must perform to generate the image • Modeling • Converting to the camera frame • Clipping • Projecting • Removing hidden surfaces • Rasterizing Suriyong L.**Modeling a Cube**• Model as 6 planes intersection or six polygons as cube facets • Ex. of cube definition GLfloat vertices[8][3] = { {-1.0,-1.0,-1.0}, {1.0,-1.0,-1.0}, {1.0,1.0,-1.0}, {-1.0,1.0,-1.0}, {-1.0,-1.0,1.0}, {1.0,-1.0,1.0}, {1.0,1.0,1.0}, {-1.0,1.0,1.0} }; // object may defined as void polygon(int a, int b, int c , int d) { /* draw a polygon via list of vertices */ glBegin(GL_POLYGON); glVertex3fv(vertices[a]); glVertex3fv(vertices[b]); glVertex3fv(vertices[c]); glVertex3fv(vertices[d]); glEnd(); } // or typedef point3[3]; // then may define as point3 vertices[8] = { {-1.0,-1.0,-1.0}, {1.0,-1.0,-1.0}, {1.0,1.0,-1.0}, {-1.0,1.0,-1.0}, {-1.0,-1.0,1.0}, {1.0,-1.0,1.0}, {1.0,1.0,1.0}, {-1.0,1.0,1.0} }; Suriyong L.**Traversal of the edges of a polygon**Inward and outward pointing faces • Be careful about the order of vertices • facing outward: vertices order is 0, 3, 2, 1 etc., obey right hand rule Suriyong L.