This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Creative Computing. Comments on Assignments Everyone did very well Report writing needs more work Jumping scale Update first then draw.
Points, Vectors, Lines, Spheres and Matrices
Lecture 7 2D Transformation. What is a transformation? Exactly what it says - an operation that transforms or changes a shape (line, shape, drawing etc.)
November 12, 2013Computer Vision Lecture 12: Texture 1Signature Another popular method of representing shape is called the signature. In order to compute.
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Translation and Rotation in 2D and 3D David Meredith Aalborg University.
TRANSFORMATIONS.
Bellwork  Perform a glide reflection of and over line y=x for the points A: (-4,2), B:(-22,-3) and C:( 0,2) No Clickers.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
, Fall 2006IAT 800 Lab 2: Polygons, Transformations, and Arrays.
Outline for Today More math… Finish linear algebra: Matrix composition
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Course Website: Computer Graphics 3: 2D Transformations.
REFLECTIONS, ROTATIONS AND TRANSLATIONS. Reflections.
CAP4730: Computational Structures in Computer Graphics
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
Week 4 - Monday.  What did we talk about last time?  Vectors.
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices.
IAT 355 Lecture 4 Computer Graphics: Rocket. May 9, 2014IAT 3552 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
Mathematical Fundamentals
Chapter 4.1 Mathematical Concepts
Physical Science Chapter 11 Motion Chapter pg.328
Some Cool Tricks.  We can consider the screen as high school graph paper.  Each sprite or object is located somewhere in the coordinate system.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
Vectors Readings: Chapter 3. Vectors Vectors are the objects which are characterized by two parameters: magnitude (length) direction These vectors are.
Vectors Chapter 3, Sections 1 and 2. Vectors and Scalars Measured quantities can be of two types Scalar quantities: only require magnitude (and proper.
General physics I, lec 1 By: T.A.Eleyan 1 Lecture (2)
7.1 – Rigid Motion in a Plane
Image Synthesis Rabie A. Ramadan, PhD D Images.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
Transforming Geometry Groundhog Day. Drawing Quads In a 300 by 200 window, draw two quads of different colors. Don’t show the grey grid.
Chapter 9 Transformations.
Graphics Matrices. Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
7.1 – Rigid Motion in a Plane
Vector components and motion. There are many different variables that are important in physics. These variables are either vectors or scalars. What makes.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Math Review.
Computation as an Expressive Medium Lab 2: Polygons, Transformations, and Arrays Evan.
AP Physics C – Vectors. 1.1 Vectors. Vectors are mathematical quantities indicated by arrows. The length of the arrow denotes the magnitude or the size.
Computer Graphics Matrices
Scalar and vector quantities 1 Starter Put a cross in the centre of your graph paper (landscape)and draw the following movement: (1 pace = 1 cm) From.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computation as an Expressive Medium Lab 2: Polygons, Transformations, and Arrays (Oh My) Micah.
 An image is the new figure, and the preimage is the original figure  Transformations-move or change a figure in some way to produce an image.
Physics and Physical Measurement Topic 1.3 Scalars and Vectors.
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
In the last several lessons, you have described translations using coordinates. You have also developed strategies for determining where an object started.
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Robotic Arms and Matrices By Chris Wong and Chris Marino.
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.
Transforms.
Computer Graphics 3: 2D Transformations
Computer Graphics 3: 2D Transformations
Review for: Unit 2 – Vectors
Polygons, Transformations, and Arrays
CSCE 441 Computer Graphics 3-D Viewing
3D Transformations Source & Courtesy: University of Wisconsin,
1.3 Vectors and Scalars Scalar: shows magnitude
Two-Dimensional Motion and Vectors
COMP 175: Computer Graphics February 9, 2016
OOP Paradigms There are four main aspects of Object-Orientated Programming Inheritance Polymorphism Abstraction Encapsulation We’ve seen Encapsulation.
COMP 175: Computer Graphics February 21, 2016
Vectors and Scalars Scalars are quantities which have magnitude only
Translate, Rotate, Matrix
Transformations.
Presentation transcript:

This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts –Graphics, 2D and 3D –Sound The course will go more into the maths and theory

Aims Understand Vectors –Position/displacement, direction, length Use Vectors in Processing programs –in 2D and 3D Understand Transforms Use Translations and Scales Use pushMatrix and popMatrix

Vectors x and y are the coordinates of points In maths we can group them together as a single object (x,y) This is called a vector

Vectors A vector can represent 2 things

Vectors A vector can represent 2 things A position on the screen (A position vector) (x,y)

Vectors A vector can represent 2 things A displacement between two points (A displacement vector) (x,y)

Vectors A position vector is really a displacement from the origin (0,0) (x,y)

Vectors Position Vectors –drawing shapes –positions of object Displacement Vectors –Velocities, movements

Maths on Vectors You can do maths on vectors Normally you do each operation on each element separately It normally help to think about vectors as displacement vectors

Vector addition add vectors (x1, y1) + (x2, y2) = (x1+x2, y1+y2) do one displacement after another (x1,y1) (x2,y2) (x1+x2,y1+y2)

Vector subtract subtract vector (x1, y1) - (x2, y2) = (x1-x2, y1-y2) The displacement of one position relative to another Very useful (x1,y1) (x2,y2) (x2+x1,y2+y1)

Length of a vector you can calculate the length (magnitude) of a vector using Pythagoras' theorem l 2 = x 2 + y 2 l = sqrt(x 2 + y 2 ) x y l

Length and direction You can think of a vector as having a length and a direction The direction is a vector that is in the same direction but of length 1 Calculate it by dividing each component of a vector by the length –(x/sqrt(x 2 + y 2 ), y/sqrt(x 2 + y 2 )) Called normalising

Length and direction Very useful to be able to think about both Length –know the distance between two objects –know how fast an something is moving (e.g. for setting a max speed) Direction –Move at a constant speed in a direction given by two points –Turn an object to face the direction its moving in

Vectors in 3D We can also do the same things in 3D An extra item, z, represents depth pass in an extra parameter OPENGL or P3D to size The maths works the same –length is sqrt(x 2 + y 2 + z 2 )

Vectors in Processing dist() gives the distance between two points –length of the displacement between them

Vectors in Processing dist() gives the distance between two points –length of the displacement between them PVector is a class for representing vectors Its new to the latest version of Processing

Exercises Rewrite my last example to use PVector make it work in 3D

Aims Understand Vectors –Position/displacement, direction, length Use Vectors in Processing programs –in 2D and 3D Understand Transforms Use Translations and Scales Use pushMatrix and popMatrix

Transformations Translate Rotate Scale

Transformations Transformations act on the whole processing screen

Transformations Translate moves the whole coordinate system by a x and y direction

Transformations Translate moves the whole coordinate system by a x and y direction

Transformations Anything before the translate call is draw normally

Transformations Anything before the translate call is draw normally Anything after the call is drawn relative to the new transformed coordinate system

Transformations Scale will change the size of the coordinates relatives to the origin (0, 0)

Transformations Scale will change the size of the coordinates relatives to the origin (0, 0)

Transformations The order of transforms is very important Changing the order changes the result

Transformations A transform applies to all the code that happens after it

Transformations A transform applies to all the code that happens after it That means it also applies to other transforms

Transformations A transform applies to all the code that happens after it Translate() Translates everything twice

Transformations A transform applies to all the code that happens after it Translate() Translates everything twice

Transformations A transform applies to all the code that happens after it A translate followed by a rotate means “apply the translate to the result of rotate”

Transformations The order of transforms is very important Translate() Rotate() Means translate the result of rotating

Transformations The order of transforms is very important Translate() Rotate() Means translate the result of rotating

Transformations The order of transforms is very important Translate() Rotate() Means translate the result of rotating

Transformations The order of transforms is very important Rotate() Translate() Means rotate the result of translating

Transformations The order of transforms is very important Rotate() Translate() Means rotate the result of translating

Transformations The order of transforms is very important Rotate() Translate() Means rotate the result of translating

Transformations This is the opposite order you would expect Translate() Rotate() Is a bit like rotating then translating

Order of transforms The normal best order is Translate Rotate Scale This means that an object is scaled the same why no matter how it is rotated It is translated the same way no matter how it is rotated

Order of transforms Rotate Translate

Order of transforms Rotate Translate

Order of transforms Rotate Translate Doesn’t end up at the end point of translating

Order of transforms Translate Rotate

Order of transforms Translate Rotate

Order of transforms Translate Rotate Rotates about its centre –if you use rectMode(CENTER) Translates to the correct position

Order of transforms Similarly if you scale an object differently along x and y and as well as rotating the order matters If you do –Scale() –Rotate() The result is no longer a rectangle (skewed) (see program)

Multiple transforms But what if we want to draw more than one thing?

Multiple transforms But what if we want to draw more than one thing? If we transform the first one then the second, the first transform will apply to the second as well

Transform Matrices A transform is represented internally as a matrix A 3D array of number The details of how doesn’t matter at the moment

Transform Matrices Up to now we have only had 1 matrix All transforms are combined together into this matrix To draw more than one object we need more than one matrix

Transform Matrices Up to now we have only had 1 matrix All transforms are combined together into this matrix To draw more than one object we need more than one matrix Multiple matrices are stored in a “Stack”

Stacks A Stack is like a stack of paper

Stacks A Stack is like a stack of paper You can put things on it –“Push” it on a stack

Stacks A Stack is like a stack of paper You can put things on it And take things off –“Pop” it off the stack

Stacks A Stack is like a stack of paper You can put things on it And take things off –“Pop” it off the stack 1 2 3

Stacks The last thing to be put on is the first to be taken off Last in, first out 1 2 3

Matrix Stacks Storing matrices as a stack means that the most recent transforms are the ones you remove first Generally what you want Global transforms that affect the whole picture are at the bottom Transforms that only affect a single object at the top

Pushing and Popping Matrices PushMatrix() creates a new matrix and puts it on the top of the stack You can then do any transforms you like PopMatrix() will then remove the matrix from the stack i.e. it will remove all the transforms you have done

Multiple Objects For multiple objects: –PushMatrix() before drawing each object –Do all the transforms for that object –PopMatrix() to get rid of the transforms before moving on to the next matrix

Transforms in 3D Translation works exactly the same in 3D need an x,y and z for the translation vector rotation is more complex: next lecture

Exercises Draw a rectangle, rotating, translating and scaling it Draw multiple rectangles in multiple positions using PushMatrix and PopMatrix Do the same with boxes in 3D