|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Apparent & absolute magnitude
I have made a simple program that calculates the absolute magnitude when you
give the distance and apparent magnitude. it can also calculate apparent magnitude and distance. You can download it at http://users.pandora.be/alex.duerloo/MAGNIT.EXE (41 Kb) If you want the code, here it is, it's written in QBasic 4.5: DECLARE FUNCTION LOGAR10! (X!) 10 DO CLS PRINT "Magnitude calculator by Alexander Duerloo (2003)" PRINT "" PRINT "" PRINT "What do you want to calculate?" PRINT "" PRINT "1. The absolute magnitude of a star" PRINT "2. The apparent magnitude of a star" PRINT "3. The distance of a star" PRINT "4. Exit" PRINT "" ch$ = INPUT$(1) ch = INT(VAL(ch$)) IF ch 0 AND ch 5 THEN EXIT DO END IF BEEP LOOP CLS SELECT CASE ch CASE 1 INPUT "What's the apparent magnitude of the star"; apmag INPUT "What's the distance of the star (in light-years)"; dist dist = dist / 3.26 abmag = apmag - ((-5) + (5 * LOGAR10(dist))) PRINT "" PRINT "The absolute magnitude of the star is "; abmag; "." PRINT "" SHELL "pause" CASE 2 INPUT "What's the absolute magnitude of the star"; abmag INPUT "What's the distance of the star (in light-years)"; dist dist = dist / 3.26 apmag = abmag + ((-5) + (5 * LOGAR10(dist))) PRINT "" PRINT "The apparent magnitude of the star is "; apmag; "." PRINT "" SHELL "pause" CASE 3 INPUT "What's the apparent magnitude of the star"; apmag INPUT "What's the absolute magnitude of the star"; abmag dist = 10 ^ (.2 * (apmag - abmag + 5)) PRINT "" PRINT "The distance of the star is "; dist * 3.26; "light-years." PRINT "" SHELL "pause" CASE 4 SYSTEM END SELECT GOTO 10 FUNCTION LOGAR10 (X) STATIC LOGAR10 = LOG(X) / LOG(10#) END FUNCTION |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Space Calendar - January 27, 2004 | Ron | Astronomy Misc | 7 | January 29th 04 09:29 PM |
Space Calendar - November 26, 2003 | Ron Baalke | History | 2 | November 28th 03 09:21 AM |
Space Calendar - November 26, 2003 | Ron Baalke | Astronomy Misc | 1 | November 28th 03 09:21 AM |
Space Calendar - October 24, 2003 | Ron Baalke | History | 0 | October 24th 03 04:38 PM |
Space Calendar - October 24, 2003 | Ron Baalke | Astronomy Misc | 0 | October 24th 03 04:38 PM |