BouncingBall

# BouncingBall - CSC 113, Fall 2010 Lab Assignment 6 This...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC 113, Fall 2010 Lab Assignment 6 This assignment develops an animation in which a ball drops due to gravity, and (with some further work) bounces back again. First we need to set up a canvas and a bounding box, which can be achieved using the following MATLAB code within a script file, that we can name “bounce.m”: figure (1); axis (’off’); % Create box xbox = [0 0 10 10 0]; ybox = [0 10 10 0 0]; bbox = line (xbox,ybox); Run the script; it should create a graphics window that looks something like this: The figure(1) command creates a figure window, and the axis(’off’) command removes the normal x- and y-axes, leaving a blank canvas. The line(xbox,ybox) command, finally, draws a box by connecting the points contained in the vectors xbox and ybox . Next, we need to create a circle, and insert it in the figure. To create a circle, we recall (from the first day of class) that the sine and cosine functions may be defined, respectively, as the y- and x-coordinates of a point on the unit circle, whose angle (in radians ) is the length of the arc from the point (1 , 0) to that point on the circle. As such, the set of ( x, y ) pairs which trace a circle may be generated as follows: 1 theta = linspace (0,2 * pi ,100); xcirc = cos (theta); ycirc = sin (theta); In effect, theta contains successive angle values in radians, running from 0 to 2 π , while xcirc and ycirc contain the x- and y-coordinates of points on the unit circle at these angular values....
View Full Document

## This note was uploaded on 02/29/2012 for the course CSC 113 taught by Professor Phillipregali during the Fall '10 term at Catholic University of America.

### Page1 / 5

BouncingBall - CSC 113, Fall 2010 Lab Assignment 6 This...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online