Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.

Slides:



Advertisements
Similar presentations
Computer Graphics - Transformation -
Advertisements

1Computer Graphics Homogeneous Coordinates & Transformations Lecture 11/12 John Shearer Culture Lab – space 2
Transformations Ed Angel Professor Emeritus of Computer Science
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
Modeling Objects by Polygonal Approximations
Transformations Objectives Understand how transformations work in 2D and 3D Understand the concept of homogenous coordinate system Understand scene graphs.
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 OpenGL Transformations Ed Angel Professor of Computer Science, Electrical and Computer.
Chapter 3: Geometric Objects and Transformations Part 2
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Computer Graphics with OpenGL 3e
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Fundamentals of Computer Graphics Part 4
Transformations Dr. Amy Zhang.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Computer Graphics Bing-Yu Chen National Taiwan University.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
PPT&Programs&Labcourse 1.
Geometric Objects and Transformation
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Geometric Objects and Transformations
CAP 4730 Computer Graphic Methods Prof. Roy Levow Chapter 4.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics I, Fall 2010 OpenGL Transformations.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
3-D Geometric Transformations
3D Geometric Transformation
3D Geometric Transformation
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Graphics Graphics Korea University cgvr.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 73 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 73 Computer Graphics Three-Dimensional Graphics II.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
Computer Graphics I, Fall 2010 Transformations.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
4. Geometric Objects and Transformations
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360/4360.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
OpenGL Transformations
Transformations Objectives
3D Geometric Transformation
OpenGL Transformations
Review: Transformations
OpenGL Transformations
Computer Graphics OpenGL Transformations
OpenGL Transformations
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Unit-5 Geometric Objects and Transformations-II
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Geometric Transformations
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Transformations in OpenGL
Transformations Ed Angel
Geometric Objects and Transformations (II)
Transformations Ed Angel Professor Emeritus of Computer Science
Isaac Gang University of Mary Hardin-Baylor
OpenGL Transformations
OpenGL Transformations
Translation in Homogeneous Coordinates
Presentation transcript:

Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실

KUCG Graphics Korea University kucg.korea.ac.kr Contents Affine transformations rotation, translation, and scaling Transformations in homogeneous coordinates Concatenation of transformations rotation about a fixed point general rotation instance transformation rotation about an arbitrary axis OpenGL transformation matrices Smooth rotation with a virtual trackball

KUCG Graphics Korea University kucg.korea.ac.kr Transformations Take a point (or vector) and map that point (or vector) into another point (or vector) P Q uv T R homogeneouscoordinate 4D column matrices transformation function

KUCG Graphics Korea University kucg.korea.ac.kr Affine Transformations (1/2) Linearity – linear function Linear transformation transform the representation of a point (or vector) into another representation of a point (or vector) 4  4 matrix vector point

KUCG Graphics Korea University kucg.korea.ac.kr Affine Transformations (2/2) Linear transformation (cont’) preserve lines – transform a line into another line  only transform the endpoints of a line segment Most transformations in CG are affine rotation, translation, scaling, and shear homogeneous coordinate affine transformation

KUCG Graphics Korea University kucg.korea.ac.kr Translation Operation that displace points by a fixed distance in a given direction displacement vector d (a) object in original position (b) object translated

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (1/2) Simple example of 2D rotation

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (1/2) Simple example of 2D rotation

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (1/2) Simple example of 2D rotation

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (2/2) Needs fixed point – a point is unchanged by the rotation rotation angle – positive rotation (counterclockwise in right hand system) rotation axis in 3D – values on axis are unchanged by the rotation (a) rotation about a fixed point(b) 3D rotation

KUCG Graphics Korea University kucg.korea.ac.kr Rigid-Body Transformations Rotation and translation No combination of rotations and translations can alter the shape of object  alter only the object’s location and orientation affine transformations, but non-rigid body transformations

KUCG Graphics Korea University kucg.korea.ac.kr Scaling (1/2) Make an object bigger or smaller uniform – scaling in all directions Affine non-rigid body transformation affine transformation: translation, rotation, scaling, shear nonuniform uniform

KUCG Graphics Korea University kucg.korea.ac.kr Scaling (2/2) Needs fixed point direction to scale scale factor  longer ( α >1) or smaller (0≤ α <1) Reflection – negative scale factor effect of scale factor reflection

KUCG Graphics Korea University kucg.korea.ac.kr Transformations in Homogeneous Coordinates Representations in homogeneous coordinates Affine transformation – 4  4 matrix

KUCG Graphics Korea University kucg.korea.ac.kr Translation Point p to p’ by displacing by a distance d translation matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Translation Point p to p’ by displacing by a distance d

KUCG Graphics Korea University kucg.korea.ac.kr Translation Point p to p’ by displacing by a distance d Inverse of a translation matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Translation Point p to p’ by displacing by a distance d Inverse of a translation matrix

KUCG Graphics Korea University kucg.korea.ac.kr Scaling Scaling matrix with a fixed point of the origin scaling matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Scaling Scaling matrix with a fixed point of the origin

KUCG Graphics Korea University kucg.korea.ac.kr Scaling Scaling matrix with a fixed point of the origin Inverse of a scaling matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Scaling Scaling matrix with a fixed point of the origin Inverse of a scaling matrix

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (1/2) Rotation with a fixed point at the origin rotation matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (1/2) Rotation with a fixed point at the origin ?

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (1/2) Rotation with a fixed point at the origin ?

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (1/2) Rotation with a fixed point at the origin

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (2/2) Inverse of a rotation matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Rotation (2/2) Inverse of a rotation matrix : orthogonal matrix

KUCG Graphics Korea University kucg.korea.ac.kr Shear (1/2) One more affine transformation shear the object in the x direction ?

KUCG Graphics Korea University kucg.korea.ac.kr Shear (1/2) One more affine transformation shear the object in the x direction

KUCG Graphics Korea University kucg.korea.ac.kr Shear (2/2) Shear in the x direction shearing matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Shear (2/2) Shear in the x direction

KUCG Graphics Korea University kucg.korea.ac.kr Shear (2/2) Shear in the x direction Inverse of a shearing matrix ?

KUCG Graphics Korea University kucg.korea.ac.kr Shear (2/2) Shear in the x direction Inverse of a shearing matrix

KUCG Graphics Korea University kucg.korea.ac.kr Concatenation of Transformations Concatenating affine transformations by multiplying together sequences of the basic transformations  define an arbitrary transformation directly ex) three successive transformations ABC pq M pq CBA

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about a Fixed Point (1/3) Fixed point: p f apply R z (  ) to rotation about a fixed point rotation of a cube about its center

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about a Fixed Point (2/3) sequence of transformations

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about a Fixed Point (3/3)

KUCG Graphics Korea University kucg.korea.ac.kr General Rotation (1/2) Three successive rotations about the three axes rotation of a cube about the z axisrotation of a cube about the y axis rotation of a cube about the x axis ?

KUCG Graphics Korea University kucg.korea.ac.kr General Rotation (2/2)

KUCG Graphics Korea University kucg.korea.ac.kr Instance Transformation (1/2) Instance of an object’s prototype occurrence of that object in the scene Instance transformation applying an affine transformation to the prototype to obtain desired size, orientation, and location instance transformation ?

KUCG Graphics Korea University kucg.korea.ac.kr Instance Transformation (2/2)

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about an Arbitrary Axis (1/6) Needs fixed point: p 0 rotation angle: θ rotation axis: vector p 2 -p 1 rotation of a cube about an arbitrary axis

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about an Arbitrary Axis (2/6) First transformation is translation T(-p 0 ) and the final one is T(p 0 ) Rotation problem!!! we can get an arbitrary rotation from three rotations about individual axes  carry out two rotations to align the axis of rotation with the z axis  rotate by θ about the the z axis movement of the fixed point to the origin

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about an Arbitrary Axis (3/6) Determine  x and  y direction angles and cosines sequence of rotations direction angles

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about an Arbitrary Axis (4/6) Determine  x and  y (cont’) projection line segment into plane y =0  look at the projection of line segment (before rotation) on the plane x =0 computation of the x rotation

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about an Arbitrary Axis (5/6) Determine  x and  y (cont’) projection line segment into z axis  rotation about y axis  caution!!! – clockwise angle computation of the y rotation

KUCG Graphics Korea University kucg.korea.ac.kr Rotation about an Arbitrary Axis (6/6) Finally concatenate all the matrices Ex) rotate an object by 45 degrees about the line passing through the origin and the point (1,2,3), fixed point is the origin solution – textbook p.195~196

KUCG Graphics Korea University kucg.korea.ac.kr OpenGL Transformation Matrices (1/2) CTM (Current Transformation Matrix) matrix that is applied to any vertex part of the pipeline  : replacement : initialization operation: : postmultiplication CTM vertices

KUCG Graphics Korea University kucg.korea.ac.kr OpenGL Transformation Matrices (2/2) Matrix modes model-view and projection matrices Three functions: rotation, translation, scaling glRotatef(angle, vx, vy, vz); glTranslatef(dx, dy, dz); glScalef(sx, sy, sz); model-viewprojection vertices CTM

KUCG Graphics Korea University kucg.korea.ac.kr Example: Rotation about a Fixed Point in OpenGL Needs fixed point: (4, 5, 6) rotation angle: 45 degrees rotation axis: the line through the origin and the point (1,2,3)

KUCG Graphics Korea University kucg.korea.ac.kr Example: Rotation about a Fixed Point in OpenGL Needs fixed point: (4, 5, 6) rotation angle: 45 degrees rotation axis: the line through the origin and the point (1,2,3) glMatrixMode(GL_MODELVIWE); glLoadIdentity( ); glTranslatef(4.0, 5.0, 6.0); glRotatef(45.0, 1.0, 2.0, 3.0); glTranslatef(-4.0, -5.0, -6.0);

KUCG Graphics Korea University kucg.korea.ac.kr Rotating a Cube (1/2) glutDisplayFunc(display); glutIdleFunc(spinCube); glutMouseFunc(mouse); void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(theta[0], 1.0, 0.0, 0.0); glRotatef(theta[1], 0.0, 1.0, 0.0); glRotatef(theta[2], 0.0, 0.0, 1.0); colorcube(); glutSwapBuffers(); } void mouse(int btn, int state, int x, int y) { if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN) axis=0; if(btn==GLUT_MIDDLE_BUTTON && state==GLUT_DOWN) axis=1; if(btn==GLUT_RIGHT_BUTTON && state==GLUT_DOWN) axis=2; }

KUCG Graphics Korea University kucg.korea.ac.kr Rotating a Cube (2/2) void spinCube(void) { theta[axis] += 2.0; if( theta[axis] > ) theta[axis] -= 360.0; glutPostRedisplay(); } void mykey(char key, int mousex, int mousey) { if( key == ‘q’ || key == ‘Q’ ) exit(); }

KUCG Graphics Korea University kucg.korea.ac.kr Rotating a Cube (2/2) glPushMatrix( ), glPopMatrix( ) perform a transformation and then return to the same state as before its execution  ex) instance transformation void spinCube(void) { theta[axis] += 2.0; if( theta[axis] > ) theta[axis] -= 360.0; glutPostRedisplay(); } void mykey(char key, int mousex, int mousey) { if( key == ‘q’ || key == ‘Q’ ) exit(); } glPushMatrix(); glTranslatef(.....); glRotatef(.....); glScalef(.....); /* draw object here */ glPopMatrix(); glPushMatrix(); glTranslatef(.....); glRotatef(.....); glScalef(.....); /* draw object here */ glPopMatrix();

KUCG Graphics Korea University kucg.korea.ac.kr Virtual Trackball (1/3) Use the mouse position to control rotation about two axes Support continuous rotations of objects trackball frame

KUCG Graphics Korea University kucg.korea.ac.kr Virtual Trackball (2/3) Rotation with a virtual trackball projection of the trackball position to the plane

KUCG Graphics Korea University kucg.korea.ac.kr Virtual Trackball (3/3) Rotation with a virtual trackball (cont’) determination of the orientation of a plane rotation angle  Quaternions

KUCG Graphics Korea University kucg.korea.ac.kr Complex Numbers (1/3) Real part + imaginary part: Addition and subtraction Scalar multiplication Multiplication y x z imaginary axis real axis

KUCG Graphics Korea University kucg.korea.ac.kr Complex Numbers (2/3) Imaginary unit: Complex conjugate modulus or absolute value Division

KUCG Graphics Korea University kucg.korea.ac.kr Complex Numbers (3/3) Representation with polar coordinates Euler’s formula Complex multiplication and division n th roots r θ z=(x, y) Imaginary axis real axis

KUCG Graphics Korea University kucg.korea.ac.kr Quaternions (1/2) One real part + three imaginary part Properties: Addition and scalar multiplication

KUCG Graphics Korea University kucg.korea.ac.kr Quaternions (2/2) Ordered-pair notation scalar ‘ s ’ + vector “ v = (a, b, c) ” Addition: Multiplication Magnitude Inverse

KUCG Graphics Korea University kucg.korea.ac.kr Quaternions and 3D Rotation For a 3D point ( α, β, γ ) a unit quaternion its conjugate  For R q is a 3D rotation about ( u x, u y, u z ) by 2θ Rotating (α, β, γ) by angle 2θ about the axis parallel to (u x, u y, u z )

KUCG Graphics Korea University kucg.korea.ac.kr Rotations with Quaternions (1/2) Rotation about any axis set up a unit quaternion ( u : unit vector) represent any point position P in quaternion notation ( p = ( x, y, z )) carry out with the quaternion operation ( q -1 =(s, –v) ) produce the new quaternion

KUCG Graphics Korea University kucg.korea.ac.kr Rotations with Quaternions (2/2) Obtain the rotation matrix by quaternion multiplication Include the translations

KUCG Graphics Korea University kucg.korea.ac.kr Example Rotation about z axis Set the unit quaternion: Substitute a=b=0, c=sin(θ/2) into the matrix: