Geometric Objects and Transformations (II)

Slides:



Advertisements
Similar presentations
Computer Graphics - Transformation -
Advertisements

Today Composing transformations 3D Transformations
1Computer Graphics Homogeneous Coordinates & Transformations Lecture 11/12 John Shearer Culture Lab – space 2
Computer Graphics 2D & 3D Transformation.
Transformations Ed Angel Professor Emeritus of Computer Science
Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
1 Geometrical Transformation 2 Outline General Transform 3D Objects Quaternion & 3D Track Ball.
CMPE 466 COMPUTER GRAPHICS
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.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.
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.
Transformations Dr. Amy Zhang.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Geometric Objects and Transformation
1 Computer Graphics Week9 -3D Geometric Transformation.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Computer Graphics I, Fall 2010 OpenGL Transformations.
2 COEN Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
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
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
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.
CSCE 441 Computer Graphics: 2D 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.
Geometric Transformations
Transformations Objectives
OpenGL Transformations
Computer Graphics CC416 Week 15 3D Graphics.
3D Geometric Transformations
OpenGL Transformations
Computer Graphics OpenGL Transformations
3D Transformations Source & Courtesy: University of Wisconsin,
Introduction to Computer Graphics CS 445 / 645
Unit-5 Geometric Objects and Transformations-II
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Chapter IV Spaces and Transforms
(c) University of Wisconsin, CS559
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Three-Dimensional Graphics
Transformations in OpenGL
Geometric Transformations
Transformations Ed Angel
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:

Geometric Objects and Transformations (II) 姜明 北京大学数学科学学院 Based on [EA], Chapter 4. 更新时间2019年2月24日星期日11时33分58秒

Outline Affine Transformations Translation, Rotation, and Scaling OpenGL Transformation Matrices Interfaces to Three-Dimensional Applications Quaternions and Rotation

Affine Transformations A transformation is a function that takes a point (or vector) and maps that point (vector) to another point (or vector). This formulation is too general to be useful. In practice, we would have to carry out the transformation on every point. E.g., to transform a line segment, a general transformation might requires to carry out the transformation for every point between the two end points. Instead, we consider a restricted class of transformations. Linear functions/transformations: The importance of this kind of transformations is that, if we know the transformations of vertices, we can obtain the transformations of linear combinations of vertices by linear combinations of transformations of the vertices. We do not have to calculate the transformations of every point.

In 4D space, a linear transformation can be represented as matrix multiplication Each linear transformation corresponds to a change in frame, as long as it is non-singular. 4x4 matrix that leaves unchanged the 4th component of a representation, 12 degree of freedom.

Transformation of Lines Suppose that we write a line in the form For any affine transform Thus, we can construct the transformed line by first transforming the start point and directional vector, and using whatever line-generation algorithm for rendering the line.

The importance of the above result in computer graphics is practical. For line segments, we need only to transform the homogeneous coordinate representation of the end points of a line segment to determine completely a transformed line. Thus, we can implement our graphics systems as a pipeline that passes endpoints through affine transformation units, and we can generate the line at the rasterization stage.

Translation Translation is defined by a displacement vector. It has 3 degree of freedom. is called the translation matrix.

Scaling It is an affine non-rigid-body transformation. There are uniform and non-uniform scalings. It has a fixed point. It has 3 degree of freedom in addition to the fixed point. is called the scaling matrix.

Shear It pulls the top to the right and bottom to the left. Y- and Z- values are not changed. This is called the X shear. is called the shear matrix.

2D Rotation

3D Rotation about Axes 2D Rotation is equivalent to 3D rotation about the Z-axis. Rotation matrices about X- and Y- axes. The negative sign of the sine term in the last matrix is consistent with our definition of a positive rotation in a right-handed system: it is counterclockwise when we look down the positive axis toward the origin.

Rotation about a Fixed Point y z x y z

Sequence of Transformations x y z x y z Translation Translation x y z x y z Rotation

General Rotation about the Origin An arbitrary rotation about the origin can be composed of 3 successive rotations about the 3 axes. We can form the desired matrix by doing first a rotation about the Z-axis, then a rotation about the Y-axis, and concluding with a rotation about the X-axis.

Rotation about an Arbitrary Axis Given A fixed point, P0, the center of the cube. A vector to rotate about, u. An angle of rotation, θ. Find the transformation matrix. The vector u can be specified by two points: u = P2 – P1.

Replace u with a unit length vector v with the same direction. Move the fixed point to the origin. Our first matrix is T(-P0). Our final one is T(P0).

Carry out two rotations to align the axis of rotation, v, with the z-axis. First onto the plane y = 0, then onto the plane x = 0. Then, rotate by θ about the z-axis. The final matrix is

The difficult part is determining θx and θy. The directional cosines

The effect of the desired rotation on the point α is to rotate the line segment into the plane y = 0.

The geometry is changed after Rx is applied. Note that the angle is clockwise about the y-axis. We have to be careful of the sign of the sine terms in the matrix.

OpenGL Transformation Matrices The Current Transformation Matrix Order of Transformations Rotation, Translation, and Scaling Rotation About a Fixed Point in OpenGL Loading, Pushing, and Popping Matrices

The Current Transformation Matrix The generalization common to most graphics systems is the current transformation matrix (CTM). It is applied to any vertex that is defined subsequent to its setting. If we change the CTM, we change the state of the system. The functions that alter CTM are of two forms: Those that reset it to some matrix: C←M. Those that modify it by post-multiplication (or pre-multiplication) by a matrix: C←CM.

Matrix Mode in OpenGL Load Matrix Matrix Mode 3D Model Vertices Stack Current Stack Current 2D 3D Vertices Modelview CTM Projection

Order of Transformations In OpenGL, the transformation specified last is the one applied first. The is a consequence of post-multiplication. Altering the CTM is similar to pushing matrices onto a stack. first in last out.

Rotation, Translation and Scaling glTranslatef (dx, dy, dz); Multiplies current matrix with translation matrix. dx, dy, and dz are translations along x,y, and z axes. glRotatef (angle, x, y, z); Multiplies current matrix with rotation about the line from the origin through the point (x, y, z) by angle. Right hand rule applies. glScalef (sx, sy, sz); Multiplies current matrix with scaling matrix. sx, sy, sz are the scale factors along the x, y, and z axes.

Rotation about a Fixed Point glMatrixMode (GL_MODEL_VIEW); glLoadIdentity (); glTranslatef (4., 5., 6.); glRotatef (45., 1., 2., 3.); glTranslatef (-4., -5., -6.); 45-degree rotation about the line through origin and the point (1,2,3) with a fixed point (4,5,6). Note the order of translations applied.

Loading, Pushing and Popping matrices glLoadIdentity (); Loads an identity matrix onto the top of the current stack glLoadMatrixf (pointer_to_matrix); Loads arbitrary matrix onto top of the current stack glMultMatrixf (pointer_to_matrix); Postmultiplies current matrix by arbitrary matrix Matricies are one-dimensional arrays of type GLfloat in column major order.

Quaternions Complex Numbers and Quaternions Quaternions and Rotation

Complex Numbers and Quaternions Rotation by complex numbers Quaternions

Operations

Quaternions and Rotation The rotation with an angle θ about a vector v=(a,b,c) can be implemented with quaternions. For an arbitrary point p=(x,y,z).

Mathematica Script for the above derivation (pdf copy) It can be proved For the matrix constructed earlier it can be shown that Mathematica Script for the above derivation (pdf copy)

Quaternions are faster and have been built into both hardware and software implementations. In addition to the efficiency, quaternions can be interpolated to obtain smooth sequences of rotations for animation.

Gimbal Lock Do We Really Need Quaternions? Why Diana Gruber's wrong about Quats Performance of quaternions in the GPU 万向节死锁(Gimbal Lock)问题