3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

Similar documents
Vector Algebra Transformations. Lecture 4

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

2D transformations: An introduction to the maths behind computer graphics

Transforms. COMP 575/770 Spring 2013

2D and 3D Transformations AUI Course Denbigh Starkey

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

GEOMETRIC TRANSFORMATIONS AND VIEWING

Computer Graphics Geometric Transformations

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

2D and 3D Coordinate Systems and Transformations

UNIT 2 2D TRANSFORMATIONS

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

Chapter 2 - Basic Mathematics for 3D Computer Graphics

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

2D/3D Geometric Transformations and Scene Graphs

(Refer Slide Time: 00:04:20)

CT5510: Computer Graphics. Transformation BOCHANG MOON

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Coordinate transformations. 5554: Packet 8 1

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

Specifying Complex Scenes

Graphics and Interaction Transformation geometry and homogeneous coordinates

Reflection (M): Reflect simple plane figures in horizontal or vertical lines;

Last week. Machiraju/Zhang/Möller/Fuhrmann

Game Engineering CS S-05 Linear Transforms

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

Geometric Transformations

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

Section III: TRANSFORMATIONS

Computer Science 336 Fall 2017 Homework 2

Polynomials. Math 4800/6080 Project Course

CSE328 Fundamentals of Computer Graphics

CS4620/5620. Professor: Kavita Bala. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

Computer Graphics: Geometric Transformations

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Introduction to Homogeneous coordinates

CS452/552; EE465/505. Geometry Transformations

GEOMETRIC OBJECTS AND TRANSFORMATIONS I

CSE528 Computer Graphics: Theory, Algorithms, and Applications

3D GRAPHICS. design. animate. render

CV: 3D sensing and calibration

Transformation. Computer Graphics October. Dr Anton Gerdelan

Computer Vision cmput 428/615

Fundamentals of Computer Animation

Affine Transformation. Edith Law & Mike Terry

DRAFT: Mathematical Background for Three-Dimensional Computer Graphics. Jonathan R. Senning Gordon College

CMSC427 Final Practice v2 Fall 2017

2D Object Definition (1/3)

Lecture 5 2D Transformation

Not exactly the translation and rotation I mean

Overview. By end of the week:

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

2D TRANSFORMATIONS AND MATRICES

Transformations. Questions on Assignment 1? Announcements

Game Engineering CS S-07 Homogenous Space and 4x4 Matrices

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

3D Computer Graphics. Jared Kirschner. November 8, 2010

Monday, 12 November 12. Matrices

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Chapter 3 - Basic Mathematics for 3D Computer Graphics

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

Image warping , , Computational Photography Fall 2017, Lecture 10

Agenda. Rotations. Camera calibration. Homography. Ransac

Coordinate Transformations & Homogeneous Coordinates

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

Vector Calculus: Understanding the Cross Product

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

Agenda. Rotations. Camera models. Camera calibration. Homographies

Lecture 9: Transformations. CITS3003 Graphics & Animation

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

Coordinate Frames and Transforms

UNIT 5: Transformations

Transformations with Matrices Moved by Matrices

Camera Model and Calibration

Basics of Computational Geometry

N-Views (1) Homographies and Projection

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Visual Recognition: Image Formation

Chapter 2: Transformations. Chapter 2 Transformations Page 1

Computer Viewing. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

2D Transformations Introduction to Computer Graphics Arizona State University

Chapter 12 Transformations: Shapes in Motion

CS354 Computer Graphics Rotations and Quaternions

Introduction to Computer Graphics with WebGL

1.5 Equations of Lines and Planes in 3-D

Matrix Operations with Applications in Computer Graphics

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

Transformations. Prof. George Wolberg Dept. of Computer Science City College of New York

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps)

Transformations: 2D Transforms

Linear and Affine Transformations Coordinate Systems

Homogeneous Coordinates and Transformations of the Plane

Transcription:

3D Mathematics Co-ordinate systems, 3D primitives and affine transformations

Coordinate Systems 2

3 Primitive Types and Topologies Primitives

Primitive Types and Topologies 4 A primitive is the most basic type of 3D object. Each primitive is defined by a set of vertices. The type of primitive is determined by the method of connection used to connect the vertices. This method of connection is referred to as the primitive topology.

Primitive Topologies: Point List 5 A point is created for each vertex in the vertex set.

Primitive Topologies: Line List 6 A line is created for each vertex pair in the vertex set. NOTE: the order of vertices in the vertex set matters!

Primitive Topologies: Line Strip 7 A line is created between each vertex and the subsequent vertex in the vertex set. Creates one continuous line.

Primitive Topologies: Triangle List 8 A triangle is create for each vertex triplet in the vertex set.

Primitive Topologies: Triangle Strip 9 A triangle is created for the first triplet in the vertex set. For each subsequent vertex in the vertex set, a triangle is created using that vertex and the previous two vertices in the vertex set.

Primitive Topologies: Triangle Fan A number of triangles are created around the first vertex in a vertex set. Not commonly used.

Triangle Winding The order in which the vertices of a triangle are specified control the winding direction. This is important as it defines the direction of the normal to the triangle. The use of this normal is discussed in a later section.

Triangle Based Rendering 2 WHY? All the vertices in a triangle are coplanar meaning that a triangle is a planar shape. This means that the triangle is the simplest primitive that creates a plane. We can approximate any other polygon by the use of triangles.

3 Constructing and Positioning 3D Objects 3D Objects

Constructing 3D Objects 4 All complex 3D objects are made up of a collection of triangle primitives. This collection of primitives is referred to as a triangle mesh. Each primitive is made up of three vertices. Meaning that a 3D mesh is simply a large vertex set.

3D Objects: Model Space 5 To correctly position all the vertices we first need a frame of reference. Each model has its own coordinate system called a SPACE. All vertices defined in the model are defined according to that space and so that space is known as MODEL SPACE.

3D Objects: World Space 6 MODEL SPACE WORLD SPACE Our scene also has its own coordinate system known as WORLD SPACE and every object has a position in the scene relative to that coordinate system.

3D Objects: World Space 7 MODEL SPACE WORLD SPACE How do we position our model in the scene? What if the model was rotated?

Positioning 3D Objects 8 To deal with rotation and positioning of objects, we need to think of in terms of positioning an objects coordinate system and not positioning the object. Since the object is defined around its coordinate system, if we transform the coordinate system then every point defined around that system will automatically be adjusted.

9 Translation, Rotation and Scaling Affine Transformations

Linear Transforms 2 A linear transform is one that preserves vector addition and scalar multiplication: f(x) kf(x) + f(y)= f(x + y) = f(kx) Scaling and rotation are linear transforms but translation is not since: t(x) t(x) = x + t t(x y) Linear transforms can be represented by a 3x3 matrix, but translation cannot so we have to make use of homogenous coordinates and 4x4 matrices. x t(y) x y t t y t

Homogenous Coordinates 2 Homogenous coordinates for an R n space are defined in an R n+ space. So for 3 dimensions we use 4 dimensional coordinates: (x,y,z,w). Homogenous means same type and in this case it refers to the fact that we can define both points and vectors using the same notation. The w element denotes a point if set to or a vector if set to. Point : w= : (x,y,z,) Direction Vector : w= : (x,y,z,) As we are now working in 4D we need a 4x4 matrix to represent our transforms.

Affine Transformations 22 To deal with the non-linearity of the translation transform we make use of affine transformations. An affine transformation is one that performs a linear transform followed by a translation. It also preserves parallelism of lines and the colinearity (all points will still lie on the same line after the transform) of points.

Affine Transformations 23 Affine transforms are represented by 4x4 matrices using homogenous coordinates. An affine transform may also be any sequence of concatenations of individual affine transforms. To apply an affine transformation you will multiply all points that need to be transformed by the transformation matrix. A rigid body transform is one that preserves distances between points transformed and handedness (i.e. never swaps left and right)

Translation Translation is the change of location and is represented by the translation matrix T which translates an entity by the vector t where t is (t x, t y, t z ). Translation is a rigid body transform 24 p t T Translation t t t t T z y x ) ( ) ( Change on X axis Change on Y axis Change on Z axis

Scaling Scaling is used to enlarge or shrink an object using the scaling factors sx, sy, sz, which affect the scaling of the object in those three axes. 25 p s S Scaling s s s s S z x y ) ( ) ( Scale on X axis Scale on Y axis Scale on Z axis

Shear 26 Shearing or Skewing is used to tilt/skew geometry, there are six basic shearing matrices: H xy (s), H xz (s), H yx (s), H yz (s), H zx (s), H zy (s) first subscript defines row Hxz( s) Shearing H s xz ( s) p Second subscript defines column H - xz (s) = H xz (-s)

Rotation The rotation transform rotates a vector by a given angle around a given axis passing through the origin. 27 cos sin sin cos ) ( Rx cos sin sin cos ) ( Ry p R Rotation z y x ) ( / / cos sin sin cos ) ( Rz NOTE: Angles are in Radians!!

Direction of Rotation 28 The direction of rotation can be calculated using a left hand or right hand rule depending on the handedness of the coordinate system in use (left/right).

Concatenations of Transforms 29 Rotation then Scaling Scaling then Rotation Since matrix multiplication is non-commutative, the order of concatenation of affine transformation matrices is very important.

Concatenations of Transforms 3 Since matrix multiplication is non-commutative, the order of concatenation of affine transformation matrices is very important. For example, if we want to scale then rotate then translate the complete transform will be: C = T R S With the order being right to left, so for each point p in an object: C = (T (R (Sp))) It is important to note that matrix multiplication is associative: C = TRSp = (TR)(Sp)

D3DX s Transforms You will notice that the matrix is multiplied with the point to be transformed, and not the point multiplied by the transformation matrix (which would be the intuitive approach) Transform of point p by matrix T = Tp Since this is not intuitive, the D3DX math library defines the transformation matrices as transposes due to the property that: Tp = p T T T 3 z y x z y x z y x z y x t t t p p p p p p t t t

The Normal Transform 32 A single affine transformation matrix can be used to transform lines, points, polygons and other geometry but cannot always be used to transform the surface normal. Translations and rotations do not affect the normal but scaling & shearing does! Uniform scaling simple affects the normal s length so the surface normal needs to be normalized (made into a unit vector again) Non-uniform scaling changes the direction of the normal and so it needs to be recalculated.

33 Rotation around a point, rotation around an arbitrary axis, Transform concatenation examples. Practical Examples of Affine Transformations

Rotation about a Fixed Point 34 The achieve rotation around a specific point, first translate the object so that point is now at the origin, then perform the required rotation and translate the object back to its original position. The complete transform X is : X = T(p)R y (θ)t(-p)

Rotation about an Arbitrary Axis 35 s (, - rz, ry ) if s (-rz,, rx ) if s s s / t r s M X (-ry, rx, M s r s t T R x ) if ( ) M rx min( ry min( rz min( rx, rx, rx, ry, ry, ry, rz rz rz ) ) ) Make Sure that r is a unit vector Find two more unit length axes (s,t) to form an orthonormal system To find s, set the smallest value to zero and swap the remaining elements and negate the first one, then normalize s. To find t: r cross product s Create matrix M, this matrix transforms vector r to the x axis, s to the y axis and t to the z axis. Rotate around x (technically r) and then reverse coordinate system transform

Transform Examples 36 We have an object centered around the point (,,) in object space. This object is positioned at (4,3,-) in world space. After we position the object, we want to rotate the object 45 degrees to the left around the Y axis. What does the final transform look like? FT = T(5,3,-) R y (-π/2) T(-5,-3,)

Space Example 37 We have a planet P at position p orbiting (rotating around its own center as well) a sun S centered at the origin (s) at a distance of units. The speed of rotation is. Radians per frame. Planet P has a moon M at position m orbiting planet P at a distance of 2 units. The moon orbits the planet at a speed of. Radians per frame. What are the transforms necessary to perform the necessary adjustments at each frame?