constellation_to_mel.1.perl
#!/usr/bin/perl





# constellations script modified by iliaskoen based (ikoen( a t )amnh.org)on a script by arlene ducao(arlduc(at )amnh.org)

# this script pulls the requested constellation from "constellations.speck"

# and turns it into a MEL file. Then it pulls each constellation-star's color,

# size, and luminance from "stars.speck"

# Open constellations.speck to find the constellation's abbreviation--

# for instance, Orion = Ori

# to download the Digital Universe atlas that includes constellations.speck,

# go to http://haydenplanetarium.org/universe/





open ( CONST_IN, "constellations.speck");

open (STARS_IN, "stars.speck");

open ( CONST_OUT, ">constellations.mel" );

print STDOUT ("what should the MEL file be called? \n ");

chop ($CONST_OUT2 = <STDIN>);

#$CONST_OUT2= join '', ">", $CONST_OUT2;

if (rename "And.mel", $CONST_OUT2) {

    print STDOUT "WORKING\n";

}

else {print STDOUT "NOT WORKING\n";}







#while-loop to go through each line of the dataset

while (defined($line = <CONST_IN>)) {

        #$x = "yo";

    $line =~ s/^\s+//;

    ($x, $y, $z,$asterix, $hip, $hipnum, $name) = split(/\s+/, $line);

    $size = 0.01;

    if ($x eq "#" || $x eq "mesh" || $x eq "1" || $x eq"" || $x eq "}") {

        ;}

     else{

    printf CONST_OUT ("polySphere -r 1 -sx 4 -sy 4 -ax 0 1 0 -tx 1 -ch 0 -name \"%s\";\n", $name);

    printf CONST_OUT ("scale -r %g %g %g;\n", $size, $size, $size);

    printf CONST_OUT ("move -r %s %s %s;\n", $x, $y, $z);

     }

}



printf STDOUT ("written to specified MEL file.\n");