This chapter introduces the concepts of modeling, data structures, and simulations as they relate to problem solving using multimedia and Java. Modeling involves describing real-world entities and their behaviors computationally. Data structures are used to organize modeling information in programs. Simulations execute models over time. The book will cover using common data structures like arrays, linked lists, and trees to structure multimedia like sound and images for animations and simulations. It will also explain why Java was chosen as the programming language. The chapter concludes by providing instructions for setting up the necessary software and files to complete the examples in the book.
1. Problem Solving with Data
Structures using Java:
A Multimedia Approach
Chapter 1: Objects for
Modeling a World
2. Todayās story
ļ¬ Whatās the point of this book?
ļ¬ Whatās a model?
ļ¬ What are data structures?
ļ¬ Why Java?
ļ¬ Details on the course
ļ¬ Getting set up for the course
3. The Point of this Book
ļ¬ Real computer-based media developers
rarely work in terms of pixels and
samples
ā¢ Computer musicians deal in terms of notes,
instruments, patches, and other structures.
ā¢ Computer animators deal in terms of
characters, movement, scenes, and other
structures
ļ¬ Bottom-line: They structure their media.
4. Driving Questions of the Book
ļ¬ How did the wildebeestās charge over the
ridge in The Lion King?
ļ¬ How did the villages wave in The
Hunchback of Notre Dame?
7. The answer: Modeling and
Simulation
ļ¬ These are two of the (rare) times that Disney
stepped away from their traditional drawn cel
animation.
ļ¬ Instead they:
ā¢ Modeled the structure of wildebeests and villagers,
ā¢ Modeled the behavior of wildebeests (how they
stampede) and villagers (how they wave),
ā¢ Then started a computer simulation that executed the
modelsā¦and basically filmed the screen.
8. Whatās āmodelingā?
ļ¬ Describing things in the world in terms of their
structure and behavior.
ā¢ F=ma (Force=mass * acceleration) is part of a model
of the world that describes what happens when one
thing hits another.
ā¢ Maps model physical spaces and their physical
relationships
ļ¬ On a computer, we can execute these models:
Make them work, plug values into equations,
move things in space, see what happens.
ā¢ Thatās simulation: Executing a model
9. Whatās a data structure?
ļ¬ A way of organizing information.
ļ¬ Different physical structures organize
space differently.
ā¢ Skyscrapers vs. ranch homes.
ā¢ Trees vs. snail shells
ļ¬ Data structures organize the information
we use in our programs in different ways.
11. Data structures that youāll come
to know
Note in Kitchen
Note in Living
Room
Note in Study
Note in Bedroom
12. Data structures have different
properties
ļ¬ Arrays and tables keep things organized
right next to one another.
ā¢ Makes it easy to find something in the array or
table
ā¢ But if you want to insert something new, you
have to move everything over.
ļ¬ Linked lists and trees keep track of
relationships with links (or edges)
ā¢ Easier to insert new things
13. Thought experiment:
Adding a second of silence into a
sound
ļ¬ Assuming that thereās room for another second
in the soundā¦
ļ¬ We copy samples from the insertion point to
the end of sound down one second:
setSampleValueAt(sound,soundIndex+oneSec,
getSampleValueAt(sound,soundIndex))
ļ¬ Then we can insert oneSecās worth of 0ās into
the insertion point
14. How that looks visually
Here is some sound
Here is some sound
One second
000000000000000Here is some sound
One second
15. Inserting into a table
Age Eye
Color
Matt 13 Brown
Jenny 7 Blue
Age Eye
Color
Matt 13 Brown
Jenny 7 Blue
Age Eye
Color
Matt 13 Brown
Jenny 7 Blue
Age Eye
Color
Katie 9 Brown
Matt 13 Brown
Jenny 7 Blue
1 2
3
4
16. Inserting into a linked list
Note in Kitchen
Note in Living
Room
Note in Study
Note in Bedroom
Note in Den
17. Modeling and Simulations are
about data structures
ļ¬ The visual structure of villagers and
wildebeests (e.g., how legs and arms attach to
bodies) is a tree or graph.
ļ¬ Tracking which villager does something next is
a queue.
ļ¬ All of the wildebeests to stampede are stored
in a list.
ļ¬ The images to be used in making the villagers
wave or wildebeests run are usually stored in a
list.
18. Learning objectives in the book
Computer Science Learning Objectives
ļ¬ Students will be able to program Java classes and methods based on
modification.
ļ¬ Students will learn how to use and manipulate several core data
structures: Arrays, linked lists, trees, stacks, and queues.
Media Learning Objectives
ļ¬ Students will be able to explain the role of data structures in structuring
and manipulating data, especially multimedia.
ļ¬ Students will be able to explain key issues of modern animations, such as
sound synchronization and moving objects in layers.
ļ¬ Students will be able to discuss the properties, strengths, and weaknesses
of the different structuring approaches for media.
ļ¬ Students will be able to design, define, and implement some simulations.
ļ¬ Students will be able to explain the value of computation for modeling and
simulation.
19. Why are we using Java?
(Why arenāt we using Python?)
ļ¬ Java is faster than Python
ā¢ We can do more operations in less time, so
we can do more complicated media in less
time.
ļ¬ Java is more well-known than Python.
ā¢ So thereās more āresume valueā than Python.
ļ¬ If you take more CS, itāll probably be in
Java.
ā¢ More CS classes are being taught now in
Java than in other programming languages.
20. General flow of book
ļ¬ Introduction to Java
ā¢ Manipulation of pictures and sounds
ā¢ Manipulating music and turtles
ļ¬ Using arrays, linked lists, and trees
ā¢ With music, pictures, and sounds
ā¢ Creating animations using arrays, lists, and trees
ā¢ Generalized linked lists and trees
ļ¬ Creating simulations
ā¢ Predator/prey, disease propagation models, movement of
people
ā¢ Different kinds of random
ā¢ Sorting our events
ā¢ Simulations with resources
ā¢ Resource queues
ā¢ Creating animations with simulations
21. Things to do to get started
ļ¬ Download and install JDK (Java Development Kit)
ā¢ http://www.java.sun.com
ļ¬ Download and install DrJava
ā¢ http://www.drjava.org
ļ¬ Download Jmusic
ā¢ http://jmusic.ci.qut.edu.au/
You need jmusic.jar and the inst instrument files
ļ¬ Download the Java source files for class
ā¢ http://www.mediacomputation.org
ļ¬ Then, tell Java where to find the JMusic and Java
source files.
25. Everything that has to be there
ā¢ Java-source
ā¢ Jmusic: inst folder, music.jar
ā¢ All jars in java-source
26. Parts of DrJava
Text of
your
class file
(.java)
Where you
interact
with Java
List of
class
files that
you have
open
Editor's Notes
Table (Matrix or Array), Organization chart (tree), Map (graph)
Excel or Word does this for you (sort of). Computer tables can only grow at the bottom.
DrJava will ask you for tools.lib first time.
Should do this live (will see it in recitation, too).
Mention: Common problem ā copying files in from CD, but becoming READ ONLY.