Let's start with the file stardata.txt
(which you should download and save to the same directory
where you are going to write
StarPlot.
The file has data for 3,526 stars labelled from
0 to 3525, with the data for
each star on a single line. Here, for example,
are the first 10 lines of the file:
0 0.994772 0.023164 4.61
1 0.97249 0.024187 5.55
2 0.435119 0.012234 5.57
3 0.998442 0.033711 6.43
4 0.998448 0.035746 6.18
5 0.873265 0.031968 2.07 ALPHERATZ
6 0.512379 0.020508 2.28 CAPH; CAS BETA
7 0.949168 0.037455 5.57
8 0.882312 0.036017 5.42
9 0.69724 0.028641 3.88
Each line has four numbers and possibly a name that
follows. The first number is the ID of the star, the
second and third are (x,y) coordinates,
and the fourth is the star's magnitude.
In the first part of this assignment, you are to read
this data from the file and plot the stars with the right magnitude.
You'll need to use DrawTool, set the XY range to be [-1,1], set the background color to be black, and the point color to be white. (Later, we'll use yellow for the constellation lines.) You might be asking ... why isn't there a Z coordinate since stars are in 3D space? This is because the view has been simplified to plot a 2D view of the sky.
The one number that needs some explanation is the magnitude. Somewhat counter-intuitively, the smaller the number, the brighter the star. Thus, you should draw a larger point for a brighter star, a smaller one for a less-bright star. You can set the size of a point in the new version of DrawTool. What you'll need to do is come up with a rule to convert the given magnitude (which ranges from -1.44 to 10.5) to a point size so that the brightest star (with magnitude -1.44) is largest. If you're curious about why this sort of "upside down" scale is used, read about it here.
2032 1987 1987 1929 1929 1813 1813 1778 1778 1687 1687 1690 1813 1690Each line has two numbers, and each number is a star ID. Thus, the two numbers 2032, 1987, on a line represent a straight line to be drawn from the star with ID 2032 to the star with ID 1987. Draw these lines in yellow. Add your code for this part to StarPlot in a separate method called plotConstellation with the following signature
static void plotConstellation (String filename, double[] x, double[] y) { // Read the data from the given file // and plot the constellation using yellow lines. }that, after plotting the stars, reads the given constellation's data and plots the lines corresponding to the constellation. Then, in main you can call this method three times for the three constellations.
5 4 3 2 1Note: there are five spaces before the 5, four spaces before the 4, ... etc. Change that program to use nested while-loops. Call your new program DiagonalWithWhile.java
Recommended, but not required: This week's theme: neurocomputing