Transformations.

Slides:



Advertisements
Similar presentations
Computer Graphics Lecture 4 Geometry & Transformations.
Advertisements

Transformations.
MIT EECS 6.837, Durand and Cutler Transformations.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
Lecture 3 – Transformation And Coordinate Systems
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM  8:50PM Presentation 2 4/7/09.
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.
Geometric Transformations Jehee Lee Seoul National University.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Transformations Jehee Lee Seoul National University.
University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction to computer vision Chapter 2: Image.
MIT EECS 6.837, Durand and Cutler Transformations.
2D Transformation. Transformation changes an object’s: – Position(Translation) – Size(Scaling) – Orientation(Rotation) – Shape(Deformation) Transformation.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Multimedia Programming 07: Image Warping Keyframe Animation Departments of Digital Contents Sang Il Park.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
Computer Graphics I, Fall 2010 Transformations.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Image Warping 2D Geometric Transformations
CSCE 441 Computer Graphics: 2D Transformations
Modeling Transformation
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
CSE 167 [Win 17], Lecture 3: Transformations 1 Ravi Ramamoorthi
Transforms.
Geometric Transformations
Transformations Objectives
3. Transformation
2D Transformations By: KanwarjeetSingh
2D Geometric Transformations
Computer Graphics CC416 Week 15 3D Graphics.
Computer Graphics Transformations.
2D Transformations with Matrices
Review: Transformations
3D Geometric Transformations
Clipping Polygon Clipping Polygon : Area primitive
Computer Graphics Transformations.
Introduction to Computer Graphics CS 445 / 645
Review: Transformations
2D Transformations y y x x y x.
Lecture 2 Transformations
COMP 175: Computer Graphics February 9, 2016
Recap from Friday Image Completion Synthesis Order Graph Cut Scene Completion.
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
2-D Geometry.
Geometric Camera Models
Announcements Midterm out today Project 1 demos.
2D transformations (a.k.a. warping)
2D Geometric Transformations
Transformations Ed Angel
Geometric Objects and Transformations (II)
Transformations Ed Angel Professor Emeritus of Computer Science
Geometrical Transformations
Isaac Gang University of Mary Hardin-Baylor
Rendering – Matrix Transformations and the Graphics Pipeline
TWO DIMENSIONAL TRANSFORMATION
Presentation transcript:

Transformations

Last Time? Ray representation Generating rays from eye point / camera orthographic camera perspective camera Find intersection point & surface normal Primitives: spheres, planes, polygons, triangles, boxes

Assignment 0 – main issues Respect specifications! Don’t put too much in the main function Use object-oriented design Especially since you will have to build on this code Perform good memory management Use new and delete Avoid unnecessary temporary variables Use enough precision for random numbers Sample a distribution using cumulative probability

Outline Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Transformations in Modeling Adding Transformations to our Ray Tracer

What is a Transformation? Maps points (x, y) in one coordinate system to points (x', y') in another coordinate system For example, IFS: x' = ax + by + c y' = dx + ey + f

Simple Transformations Can be combined Are these operations invertible? Yes, except scale = 0

Transformations are used: Position objects in a scene (modeling) Change the shape of objects Create multiple copies of objects Projection for virtual cameras Animations

Outline Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Transformations in Modeling Adding Transformations to our Ray Tracer

Rigid-Body / Euclidean Transforms Preserves distances Preserves angles Rigid / Euclidean Identity Translation Rotation

Similitudes / Similarity Transforms Preserves angles Similitudes Rigid / Euclidean Identity Translation Isotropic Scaling Rotation

Linear Transformations Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear

Linear Transformations L(p + q) = L(p) + L(q) L(ap) = a L(p) Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear

Affine Transformations preserves parallel lines Affine Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear

Projective Transformations preserves lines Projective Affine Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear Perspective

Perspective Projection

General (free-form) transformation Does not preserve lines Not as pervasive, computationally more involved Won’t be treated in this course From Sederberg and Parry, Siggraph 1986

Outline Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Transformations in Modeling Adding Transformations to our Ray Tracer

How are Transforms Represented? x' = ax + by + c y' = dx + ey + f x' y' a b d e x y c f = + p' = M p + t

Homogeneous Coordinates Add an extra dimension in 2D, we use 3 x 3 matrices In 3D, we use 4 x 4 matrices Each point has an extra value, w x' y' z' w' a e i m b f j n c g k o d h l p x y z w = p' = M p

Translation in homogenous coordinates x' = ax + by + c y' = dx + ey + f Affine formulation Homogeneous formulation x' y‘ 1 a b d e 0 0 c f 1 x y 1 x' y' a b d e x y c f = = + p' = M p + t p' = M p

Homogeneous Coordinates Most of the time w = 1, and we can ignore it If we multiply a homogeneous coordinate by an affine matrix, w is unchanged x' y' z' 1 a e i b f j c g k d h l 1 x y z 1 =

Homogeneous Visualization Divide by w to normalize (homogenize) W = 0? Point at infinity (direction) (0, 0, 1) = (0, 0, 2) = … w = 1 (7, 1, 1) = (14, 2, 2) = … (4, 5, 1) = (8, 10, 2) = … w = 2

Translate (tx, ty, tz) Translate(c,0,0) y Why bother with the extra dimension? Because now translations can be encoded in the matrix! p p' x c x' y' z' 1 x' y' z' 1 1 1 tx ty tz 1 x y z 1 =

Scale (sx, sy, sz) Isotropic (uniform) scaling: sx = sy = sz x' y' z' Scale(s,s,s) y p' Isotropic (uniform) scaling: sx = sy = sz p q' q x x' y' z' 1 sx sy sz 1 x y z 1 =

Rotation About z axis x' y' z' 1 cos θ sin θ -sin θ cos θ 1 1 x y z 1 ZRotate(θ) y p' About z axis θ p x z x' y' z' 1 cos θ sin θ -sin θ cos θ 1 1 x y z 1 =

Rotation Rotate(k, θ) y About (kx, ky, kz), a unit vector on an arbitrary axis (Rodrigues Formula) θ k x z x' y' z' 1 kxkx(1-c)+c kykx(1-c)+kzs kzkx(1-c)-kys kzkx(1-c)-kzs kzkx(1-c)+c kzkx(1-c)-kxs kxkz(1-c)+kys kykz(1-c)-kxs kzkz(1-c)+c 1 x y z 1 = where c = cos θ & s = sin θ

Storage Often, w is not stored (always 1) Needs careful handling of direction vs. point Mathematically, the simplest is to encode directions with w=0 In terms of storage, using a 3-component array for both direction and points is more efficient Which requires to have special operation routines for points vs. directions

Outline Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Transformations in Modeling Adding Transformations to our Ray Tracer

How are transforms combined? Scale then Translate (5,3) Scale(2,2) (2,2) Translate(3,1) (1,1) (3,1) (0,0) (0,0) Use matrix multiplication: p' = T ( S p ) = TS p 1 1 1 3 1 1 2 2 1 2 2 3 1 TS = = Caution: matrix multiplication is NOT commutative!

Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p (5,3) Scale(2,2) (2,2) Translate(3,1) (1,1) (3,1) (0,0) (0,0) Translate then Scale: p' = S ( T p ) = ST p (8,4) Translate(3,1) (4,2) Scale(2,2) (1,1) (6,2) (3,1) (0,0)

Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p 1 1 3 1 2 2 1 2 2 3 1 TS = = Translate then Scale: p' = S ( T p ) = ST p 2 1 2 1 1 1 3 1 1 2 2 6 2 ST = =

Today Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Transformations in Modeling Adding Transformations to our Ray Tracer

Transformations in Modeling Position objects in a scene Change the shape of objects Create multiple copies of objects Projection for virtual cameras Animations

Scene Description Scene Materials (much more next week) Camera Lights Background Objects

Simple Scene Description File OrthographicCamera { center 0 0 10 direction 0 0 -1 up 0 1 0 size 5 } Lights { numLights 1 DirectionalLight { direction -0.5 -0.5 -1 color 1 1 1 } } Background { color 0.2 0 0.6 } Materials { numMaterials <n> <MATERIALS> } Group { numObjects <n> <OBJECTS> }

Class Hierarchy Object3D Cone Sphere Cylinder Triangle Plane Group

Why is a Group an Object3D? Logical organization of scene

Ray-group intersection Recursive on all sub-objects

Simple Example with Groups numObjects 3 Box { <BOX PARAMS> } Box { <BOX PARAMS> } } numObjects 2 Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } Plane { <PLANE PARAMS> } }

Adding Materials Group { numObjects 3 Material { <BLUE> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } numObjects 2 Material { <BROWN> } Material { <GREEN> } Material { <RED> } Sphere { <SPHERE PARAMS> } Material { <ORANGE> } Sphere { <SPHERE PARAMS> } } } Material { <BLACK> } Plane { <PLANE PARAMS> } }

Adding Transformations

Class Hierarchy with Transformations Object3D Cone Cylinder Group Sphere Plane Transform Triangle

Why is a Transform an Object3D? To position the logical groupings of objects within the scene

Simple Example with Transforms Group { numObjects 3 Transform { ZRotate { 45 } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } } Translate { -2 0 0 } numObjects 2 Box { <BOX PARAMS> } } Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } } Plane { <PLANE PARAMS> } }

Nested Transforms p' = T ( S p ) = TS p same as Translate Translate Scale Scale same as Sphere Sphere Transform { Translate { 1 0.5 0 } Scale { 2 2 2 } Sphere { center 0 0 0 radius 1 } } } Transform { Translate { 1 0.5 0 } Scale { 2 2 2 } Sphere { center 0 0 0 radius 1 } }