, Fall 2006IAT 800 Lab 2: Polygons, Transformations, and Arrays.

Slides:



Advertisements
Similar presentations
What is similar about these objects?
Advertisements

Objects. 2 Object Oriented Programming (OOP) OOP is a different way to view programming Models the real world A different view than Structured programming.
18/2/00SEM107 - © Kamin & Reddy Class 7 - LineList - 1 Class 7 - Line Drawings  The LineList data type r Recursive methods to construct line drawings.
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.
Programming in Processing Taught by Ms. Madsen Assistants: Ms. Fischer and Ms. Yen Winsor School, 2/13/08.
A Quick Introduction to Processing
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Introduction to Geometry Designer For iPad. Launching the App To turn on the iPad, press the Home button Find the Geometry Designer app and tap on it.
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
IAT 334 Lab 2 Computer Graphics: Rocket, PImage. June 4, 2010IAT 3342 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
Translate, Rotate, Matrix Pages Function Function Definition Calling a function Parameters Return type and return statement.
Translation and Rotation in 2D and 3D David Meredith Aalborg University.
Polygons – Sum of the Angles The sum of the interior angles of a convex polygon depends on the number of sides of the polygon. The formula is developed.
You will need your think book.. Review… An angle is … Draw an angle with points A, B, C Label the angle ABC or CBA Point to the vertex of the angle. A.
CS 106 Introduction to Computer Science I 12 / 06 / 2006 Instructor: Michael Eckmann.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2011.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
IAT 800 Lecture 4. Sept 18, Fall 2006IAT 8002 Outline  Programming concepts –Methods –Classes  Talk about project 1  Reading: Read Chapters 1-4 of.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
Oct 17, Fall 2006IAT 800 ArrayList, Text, and more Image Manipulation.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
IAT 800 Lecture 8. Oct 13, Fall 2006IAT 8002 Outline  Programming concepts –BImage BFont –Creating XImage –Typography.
IAT 355 Lecture 4 Computer Graphics: Rocket. May 9, 2014IAT 3552 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Today we will derive and use the formula for the area of a triangle by comparing it with the formula for the area of a rectangle. derive = obtain or receive.
+ Module 7 Lesson 5 Compare and classify quadrilaterals.
Google Sketchup Lab Mr. Garner Tech Ed Lime Kiln MS.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Geometers Sketch pad. Step 1: Open Sketch pad Use this to select items Use this to draw a point Use this to draw a circle Use this to draw a line Use.
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
Transforming Geometry Groundhog Day. Drawing Quads In a 300 by 200 window, draw two quads of different colors. Don’t show the grey grid.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Introduction to Using the Notebook 10 Software for SMART Board Day 2 LIVINGSTON PARISH PUBLIC SCHOOLS Facilitated by S. Waltman.
 Students will be able… › Identify reflections, rotations, and translations. › Graph transformations in the coordinate plane.
Geometric transformations!
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
E9 Students are expected to make generalizations about the properties of translations and reflections and apply these properties. E10 Students are expected.
Computation as an Expressive Medium Lab 2: Polygons, Transformations, and Arrays Evan.
WHICH IS WHICH? WHAT CAN WE DO TO REMEMBER? Look at reflection, translation and rotation.
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
Step One Draw a square on your paper. Step Two Beginning in the top left corner of the square, measure to the right about a half inch and place a dot.
Rotations. Goals Distinguish between a translation, reflection, and rotation. Visualize, and then perform rotations using patty paper. To determine the.
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
Week 8 - Friday.  What did we talk about last time?  Static methods.
FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.
Chapter 4-1: Measures of Angles as Rotations. Review… Angle: The union of two rays which are its sides with the same vertex or endpoint. Angle: The rotation.
Vertices, Curves, Color, Images mostly without details 02/16/2010.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
Computation as an Expressive Medium Lab 2: Polygons, Transformations, and Arrays (Oh My) Micah.
IAT 265 Images in Processing PImage. Jun 27, 2014IAT 2652 Outline  Programming concepts –Classes –PImage –PFont.
First of all – lets look at the window’s you are going to use. At the top you have a toolbar, with all your various tools you can use when customising.
IAT 800 Lecture 8 PImage and PFont. Oct 13, Fall 2009IAT 8002 Outline  Programming concepts –PImage –PFont.
Algebra Tiles How to sort, making the equation smaller and easier: 2x+1x+3 to 3x+3 How to make zero pairs, 1x+-1x=0, then take them away from the equation.
In the last several lessons, you have described translations using coordinates. You have also developed strategies for determining where an object started.
Functions. functions: a collection of lines of code with a name that one can call. Functions can have inputs and outputs.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
Programming in Processing Taught by Ms. Madsen Assistants: Ms. Fischer and Ms. Yen Winsor School, 2/20/08.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Computer Graphics: Rocket, Java: Class
Chapter 14, Translate & Rotate
Polygons, Transformations, and Arrays
CS/COE 0447 (term 2181) Jarrett Billingsley
LCC 6310 Computation as an Expressive Medium
IAT 265 Lecture 2: Java Loops, Arrays Processing setup, draw, mouse Shapes Transformations, Push/Pop.
Translate, Rotate, Matrix
Computation as an Expressive Medium
Presentation transcript:

, Fall 2006IAT 800 Lab 2: Polygons, Transformations, and Arrays

, Fall 2006IAT 800 Today  Arrays  Building Complex Shapes  Translation and Rotation  Pushing and Popping

, Fall 2006IAT 800 Arrays  Arrays store lists of values  Access items by index number

, Fall 2006IAT 800 Building Special Shapes  The beginShape() and endShape() functions allow us to draw irregular shapes from any number of points we define.  Many types of Shape: –POINTS, LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN, QUADS, QUAD_STRIP, POLYGON –POLYGON will be the most useful. …

, Fall 2006IAT 800 Building Polygons  beginShape(POLYGON); –Tells the program to start the polygon.  vertex(x, y); –Make as many calls to this as you have vertices in your polygon.  endShape(); –Finishes the shape, connecting the last vertex to the first vertex to close the polygon, then colors it with the current fill() color.

, Fall 2006IAT 800 Building Polygons  beginShape(POLYGON);  vertex(10, 50); (starts a new polygon, and begins at point (10, 50).)

, Fall 2006IAT 800 Building Polygons  vertex(20, 10);  vertex(30, 40);  vertex(80, 60);  vertex(40, 80); (adds 4 more points to the polygon, and connects them in the order they are called.)

, Fall 2006IAT 800 Building Polygons  endShape(); (connects the last point to the first point, and fills the polygon.)

, Fall 2006IAT 800 Let’s Use Arrays  Let’s store the points that we’re drawing. int[] xvals = {10, 20, 30, 80, 40}; int[] yvals = {50, 10, 40, 60, 80}; beginShape(POLYGON); for(int i = 0; i < xvals.length; i++) { vertex(xvals[i], yvals[i]); } endShape();

, Fall 2006IAT 800 Let’s Use Arrays  Well, we can also use those arrays to draw the same shape somewhere else. beginShape(POLYGON); for(int i = 0; i < xvals.length; i++) { vertex(xvals[i] + 10, yvals[i] + 10); } endShape();

, Fall 2006IAT 800 This is not very general  What if you wanted to move by some other value?  Need a general method of moving polygons of some given shape

, Fall 2006IAT 800 Translation  Translation gives us another way of drawing in a new location. It in essence, moves the point (0, 0) in our window. (0, 0) beginShape(POLYGON); for(int i = 0; i < xvals.length; i++) { vertex(xvals[i], yvals[i]); } endShape();

, Fall 2006IAT 800 Translation  After the call to translate(), any drawing functions called will treat our new orange point as if it were (0, 0). (10, 10) translate(10, 10); (0, 0)

, Fall 2006IAT 800 Translation  So now, if we write the exact same polygon code as above, the new polygon will be 10 pixels down and 10 pixels to the right. (10, 10) beginShape(POLYGON); for(int i = 0; i < xvals.length; i++) { vertex(xvals[i], yvals[i]); } endShape(); (0, 0)

, Fall 2006IAT 800 Rotation  Much like Translation, Rotation moves our drawing space, so that we can draw at different angles.  Most of the time, you’ll want to use Rotation in conjunction with Translation, because rotate() rotates the drawing window around the point (0, 0).

, Fall 2006IAT 800 Rotation  Let’s look at an example without translation: rect(10, 10, 50, 50); (0, 0)

, Fall 2006IAT 800 Rotation  Make a variable with the value for 45 degrees in Radians. float angle = radians(45); (0, 0) ( radians() takes an int or float degree value and returns a float radian value. If you’re confused about the concept of radians, ask me afterward.)

, Fall 2006IAT 800 Rotation  Rotate our drawing canvas 45 degrees around the origin. rotate(angle); (0, 0) (You can see that one problem now is that much of our drawing canvas is now outside of the window.)

, Fall 2006IAT 800 Rotation  Draw the same square, now relative to our rotated canvas. rect(10, 10, 50, 50); (0, 0) (We only get to see about half of our square, and it isn’t really rotated in any satisfactory way.)

, Fall 2006IAT 800 Rotation  Let’s try this from the start, using translation.  Where should we translate to? –The point around which we want to rotate. So let’s try and rotate around the center of the square. –This means moving the origin, and drawing the square around it.

, Fall 2006IAT 800 Rotation  Let’s start with setting our rotation point: translate(35, 35); (0, 0) (35, 35)

, Fall 2006IAT 800 Rotation  Now let’s draw a square with this point at its center. rect(-25, -25, 50, 50); (0, 0) (35, 35)

, Fall 2006IAT 800 Rotation  Then let’s do the same rotate we did last time. float angle = radians(45); rotate(angle); (0, 0) (35, 35)

, Fall 2006IAT 800 Rotation  Now when we draw the same square as before, it will have the same center point. float angle = radians(45); rotate(angle); (0, 0) (35, 35)

, Fall 2006IAT 800 Rotation  Try applying rotation to your animations using draw(). What variable will you want to iterate to make a shape rotate over time?  Try making a custom polygon rotate instead of a square.

, Fall 2006IAT 800 Wait! How do I get back to normal?!  If you plan to do a lot of translations and rotations, it helps to know about the concepts of push and pop… (0, 0) (35, 35) (60, 15) I just want to go back to where I started before this!

, Fall 2006IAT 800 Pushing and Popping  Pushing is a way to say: –“Remember this orientation!” –PushMatrix();  Popping is a way to say: –“Take me back to the way things once were!” –PopMatrix();

, Fall 2006IAT 800 Push & Pop …IN ACTION!  If we want to remember the original orientation… pushMatrix(); translate(35,35); rotate( radians(45) ); rect(-25,-25,50,50); popMatrix(); rect(-25,-25,50,50); (0, 0) You can push and pop as many times as you want. It’s like you’re writing an address for the way things were on a card, and putting it on a stack each time you push… and pop just takes the first card off the top of the stack. (35, 35)

, Fall 2006IAT 800 How is this useful?  You don’t have to remember the math to reverse all the translations and rotations you’ve done!  You can make spiral shapes, then go back to normal!  You can make drawings with limbs! (You don’t want to have to calculate the angles of every finger, do you?)

, Fall 2006IAT 800 Review  Arrays  Drawing Polygons  Translation and Rotation  PushMatrix and PopMatrix  Go over building your own methods? (no slides)