Assignments | Class Photo | Course Home | Lab Hours/Tutoring | MATLAB info | Schedule | Submit

Saint Louis University

Computer Science 145
Scientific Programming

Michael Goldwasser

Spring 2009

Dept. of Math & Computer Science

Assignment 08

Stars and Constellations


Contents:


Overview

Topic: Stars and Constellations
Related Reading: file I/O, plotting
Due: Wednesday, 15 April 2009, 11:59pm


Collaboration Policy

For this assignment, you must work individually in regard to the design and implementation of your project.

Please make sure you adhere to the policies on academic integrity in this regard.


The Goal

Our goal for this problem is to create an image based upon underlying data about the stars and constellations. Our version of the project is a variant of a nifty assignment designed by Karen Reid at the University of Toronto.

As an example, here is a figure that shows a view of the night sky (click on the image for a larger version):

Here is a second version of the image that also includes the display of several major constellations.


Data File Format

The raw data for this assignment is provided in the form of two different text files:


The Matlab Figure

To get the basic star image in Matlab, we rely upon the scatter command. We use the form scatter(X,Y,S,C,'filled') where X is a vector of x-values, Y is a vector of y-values, S is a corresponding vector of scales (brightnesses for our application), and C designates color. For this assignment, we use 'w' as the color for all stars. The final parameter 'filled' designates that the circles should be drawn as filled rather than the default outline.

To plot white stars against a black background, we need to configure the basic figure window. As with previous plots, it is also important that we force the two axes to be drawn with an equivalent scale so that the image is circular. You may use the following function in order to setup the figure window.

function plotSky
   % This sets up a basic figure window for our plot of the sky.
   % It sets the background to black and sets the axes to be
   % equal but undisplayed.
   %
   % This function leaves the size as the default, but the user
   % can manually resize the figure window for a larger view.
   clf;
   hold off;               % start a new figure
   axis equal;             % ensure equal treatment of x and y axes
   axis off;               % do not display the actual axes
   set(gcf,'Color','k');   % set background color to black
   hold on;

The constellation line segments are drawn based on the use of the plot command for each individual line segment, using the x and y coordinates for the two designated stars. To get all segments from the same constellation in the same color, but different constellations in different colors, we use the following hack. We have a string 'ymcrgb' which contains six character codes for the colors yellow, magenta, cyan, red, green, and blue. For each constellation, we pick one of those characters and use it when calling plot to control the color. Then when we move to a new constellation, we advance one character in that control string (wrapping around to the beginning if necessary).

Although we expect that in completing this assignment, you should start by working on the function to plot the stars, and then the function to plot the constellation, the final image will look nicer if you plot the constellations first and the stars second, because then the stars will be drawn on top of the constellation lines (making it easier to see the stars that define the constellations).

As af final note, our image includes a legend to identify the names of the constellations. Providing that feature is considered extra credit for the sake of this assignment.


Your Task

To divide up the work more clearly, you are to write four different functions, described as follows.


Extra Credit (2 points)

Generate the legend when plotting the constellations.


Michael Goldwasser
CSCI 145, Spring 2009
Last modified: Tuesday, 14 April 2009
Assignments | Class Photo | Course Home | Lab Hours/Tutoring | MATLAB info | Schedule | Submit