FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.

Slides:



Advertisements
Similar presentations
Creative Computing. Comments on Assignments Everyone did very well Report writing needs more work Jumping scale Update first then draw.
Advertisements

Variables Conditionals Boolean Expressions Conditional Statements How a program produces different results based on varying circumstances if, else if,
Is the shape below a function? Explain. Find the domain and range.
Image Processing … computing with and about data, … where "data" includes the values and relative locations of the colors that make up an image.
Recursion October 5, Reading Read pp in the text.
Emerging Platform#5: Processing 2 B. Ramamurthy 6/13/2014B. Ramamurthy, CS6511.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
© Calvin College, Being abstract is something profoundly different from being vague... The purpose of abstraction is not to be vague, but to create.
Basic Spreadsheet Functions Objective Functions are predefined formulas that perform calculations by using specific values, called arguments, in.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2011.
BASIC FUNCTIONS OF EXCEL. Addition The formula for addition is: =SUM( insert cells desired to sum up ) This returns the sum of the selected cells.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2010/2011.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2010/2011.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2011.
cell (letter- number) Column (letters) Row (numbers) workbook = collection of worksheets.
Math – Getting Information from the Graph of a Function 1.
FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.
2D Graphics: Part 2.
Arrays One-Dimensional initialize & display Arrays as Arguments Part I.
Quantifying the dynamics of Binary Search Trees under combined insertions and deletions BACKGROUND The complexity of many operations on Binary Search Trees.
Greedy Backtracking ? ? ? ?.  Fast, low complexity, gives acceptable solution (not necessarily the best)  At each step choose the best option considering.
02 – Object Modeling Overview Point Selection Bounding Box Line Equation Least Square Line Equation Conclusions.
Variables and Arithmetic. From last class More drawing functions: strokeWeight(n); // higher the n value broader the stroke fill(k) ; // single parameter.
Review of ArT3 Programming Course David Meredith Aalborg University
Functions. Functions are named blocks of code. Functions allow complex programs to be broken down into smaller, simpler tasks. Functions allow commonly.
Introduction to Image processing using processing.
B. RAMAMURTHY Simulating Motion and Implementing Animation.
CIS 3.5 Lecture 2.2 More programming with "Processing"
Arrays. An array is a collection “The Dinner offers an array of choices.” In computer programming, an array is a collection of variables of the same data.
FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.
1 Lab 1. C Introduction  C: –Developed by Bell lab. in –a procedure-oriented programming language.  Developing environments: –Editing –Preprocessing.
Objects. The Heart of the Matter - The "Black Box" Object-oriented software is all about objects. An object is a "black box" which receives and sends.
Lesson Two: Everything You Need to Know
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
Computer Science I Arrays. Parallel structures. Classwork/Homework: Build your own bouncing things.
Programming for Art: Arrays ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 01 Fall 2010.
LAB SESSION ONE DIMENSIONAL ARRAY.
Welcome back!. Object Oriented Programming – Encapsulation Classes encapsulate state (fields) and behavior (methods) – Polymorphism Signature Polymorphism.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
Computer Programming for Engineers
Dynamics of Binary Search Trees under batch insertions and deletions with duplicates ╛ BACKGROUND The complexity of many operations on Binary Search Trees.
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 3. Time Complexity Calculations.
Review Objects – data fields – constructors – Methods Classes.
Arrays. 2 Why do we care (about arrays)? What if you have a whole bunch of cars (or aliens or balls or ???) bouncing around the screen? How do we keep.
Created by: Tonya Jagoe. Measures of Central Tendency & Spread Input the data for these test scores into your calculator to find.
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
Functions. 2 Modularity What is a function? A named block of code Sometimes called a ‘module’, ‘method’ or a ‘procedure’ Some examples that you know are:
Emerging Platform#1: Processing 3
Chapter 14, Translate & Rotate
For Net Art Lecture 2 J Parker
Exam1 Review CSE113 B.Ramamurthy 11/29/2018 B.Ramamurthy.
Constructor Laboratory /12/4.
Part (a) y = ex y = ln x /2 Area = (ex - ln x) dx
Variables and Arithmetic
2.1(c) Notes: Quadratic Functions
Homework Analyzing Graphs
Embarrassingly Parallel Computations
Programming for Art: Images
Just a question for Mac users:
Exam1 Review CSE113 B.Ramamurthy 4/17/2019 B.Ramamurthy.
Trigonometry & Random March 2, 2010.
How About Some PI? Trigonometry Feb 18,2009.
Analysis of Absolute Value Functions Date:______________________
Continuous & Random September 21, 2009.
Chapter 13, Math A few Examples.
Review Trigonometry review, SOHCAHTOA
Presentation transcript:

FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012

ASSIGNMENT 2 DUE DATE 27 NOV 2012 COLLECTION VIA ACS

REQUIREMENTS o Design and simulate set of objects (20%) o e.g. germs, ants, cars, o Use of "for" statements and “array” data structures (20%) o With interaction among objects (30%) o Creative object behaviors (30%) o Note that graphic is not important in this assignment

EXAMPLE

EXAMPLE – SIMPLE GERMS int n = 80; float ballSize = 5; float[] x = new float[n]; float[] y = new float[n]; float[] sx = new float[n]; float[] sy = new float[n]; void setup() { size(200, 200); smooth(); for (int i=0; i<n; i++) { x[i] = random(10, width-10); y[i] = random(10, height-10); sx[i] = random(-1, 1); sy[i] = random(-1, 1); } Define and initialization data (arrays)

EXAMPLE – SIMPLE GERMS void move() { for (int i=0; i<n; i++) { x[i] += sx[i]; y[i] += sy[i]; if (x[i] < 0) { x[i] = 0; sx[i] = -sx[i]; } if (x[i] > width) { x[i] = width; sx[i] = -sx[i]; } if (y[i] < 0) { y[i] = 0; sy[i] = -sy[i]; } if (y[i] > height) { y[i] = height; sy[i] = -sy[i];} } How objects move

EXAMPLE – SIMPLE GERMS void draw() { background(200); for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { float d = dist(x[i], y[i], x[j], y[j]); if (d < 30) { float c = map(d, 0, 30, 0, 200); stroke(c); line(x[i], y[i], x[j], y[j]); } stroke(0); fill(255); for (int i=0; i<n; i++) { ellipse(x[i], y[i], ballSize, ballSize); } move(); } How objects display

EXAMPLE – SIMPLE GERMS for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { if (i != j) { float dx = 1 / (x[i] - x[j]); float dy = 1 / (y[i] - y[j]); dx = constrain(dx, -0.9, +0.9); dy = constrain(dy, -0.9, +0.9); sx[i] += dx; sy[i] += dy; sx[i] = constrain(sx[i], -3, +3); sy[i] = constrain(sy[i], -3, +3); } How objects interact with each other (insert this to function move() )

USEFUL FUNCTIONS & REFERENCES o map (value, low1, high1, low2, high2) o Re-maps a number from one range to another o constrain(value, min, max) o Constrains a value to not exceed a maximum and minimum value. o abs(value) o Calculates the absolute value (always position) of a number.