![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
maybe you should move on to another newsgroup where you can fully express
your psychological problems, cypherpunk that would make us all happy schreef in bericht ... Alexander Duerloo wrote: 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: BEEP Heh - kids. |
#3
|
|||
|
|||
![]()
"Alexander Duerloo" wrote in message
... by the way, what do you mean with low-quality code schreef in bericht ... Alexander Duerloo wrote: maybe you should move on to another newsgroup where you can fully express your psychological problems, cypherpunk that would make us all happy And maybe you should not post such poor quality source code to the Internet, if you want to avoid ridicule. Don't let the flamers get you down, Alexander. At least you contributed some technical content. We could do with more of it, and at all levels of expertise. If you enjoy tinkering with BASIC code in an astronomy vein, I invite you to take a look at the contents of The Orrery newsletter: http://members.attcanada.ca/~gneill/ |
#5
|
|||
|
|||
![]()
look, cypherpunk: if insulting other people at an astronomy newsgroup makes
you feel cool, then do it. I don't care because most of the people in this newsgroup ignore you and your posts becaus the are ridiculous, antisocial and insulting messages schreef in bericht ... wrote: wrote: Alexander Duerloo wrote: by the way, what do you mean with low-quality code No matter how trivial you feel it is to read the source code, you should have COMMENTS documenting the program flow and algorithms. It's the difference between amateur and professional. Reason: 85% of the cost of source code is in the maintenance. That's partly true (although a lot of "professional" code I've worked with has been very poorly documented) but Alexander wasn't posting this as an all-singing-all-dancing professional package, just as something of interest for the astronomical community. At least it's on topic and useful, which is a pleasant change from a lot of recent postings.... Yeah, he was trying to be helpful. It's just a shame to see him using bad habits which will be hard to shake later. I seem to recall there were "magic" numbers in his code too. (unexplained constants) If he's going to donate code to people to learn from, it would be good form to take a few extra minutes to comment it up. Nothing wrong with BASIC, BTW. |
#6
|
|||
|
|||
![]()
On Sat, 12 Jul 2003 12:43:34 +0100, Alexander Duerloo wrote:
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: Thanks Alexander. It is a nice little program. I am sure I shall use it. Its a long time since such a little gem appeared in this ng. -- Gautam Majumdar |
#7
|
|||
|
|||
![]()
Here are the formulas used in the program:
M=Absolute magnitude m=Apparent Magnitude d=Distance (parsec) M = m - ((-5) + 5 log d) m = M + ((-5) + 5 log d) d = 10 ^ (0.2 (m - M + 5)) If you are smarter than you seem to be you could now easily reconstruct the program |
#8
|
|||
|
|||
![]()
In article ,
wrote: It's been years since I stopped doing math and switched to using the computer (lots of numbers, but for abstracts), but I think I remember e: 2.71828184590452356... ....except that it should read: 2.71828182845904523536028747135... ....so you skipped a "28" sequence there..... and your last digit shouldn't be 6..... :-) Personally I remember it this far: 2.718281828 The repetition of "1828" is what I remember most easily. -- ---------------------------------------------------------------- Paul Schlyter, Grev Turegatan 40, SE-114 38 Stockholm, SWEDEN e-mail: pausch at stockholm dot bostream dot se WWW: http://www.stjarnhimlen.se/ http://home.tiscali.se/pausch/ |
#9
|
|||
|
|||
![]()
Paul Schlyter wrote:
In article , wrote: It's been years since I stopped doing math and switched to using the computer (lots of numbers, but for abstracts), but I think I remember e: 2.71828184590452356... ...except that it should read: 2.71828182845904523536028747135... ...so you skipped a "28" sequence there..... and your last digit shouldn't be 6..... :-) Personally I remember it this far: 2.718281828 The repetition of "1828" is what I remember most easily. The "459" isn't hard either. 1828 = the year after Beethoven died 4, 5, 9 = his three most widely known symphonies At least that's how my applied math teacher explained it, and it must work, because almost 30 years later I still remember it. :-) -- Bill |
#10
|
|||
|
|||
![]()
no problem
|
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Space Calendar - November 26, 2003 | Ron Baalke | History | 2 | November 28th 03 09:21 AM |
Space Calendar - October 24, 2003 | Ron Baalke | History | 0 | October 24th 03 04:38 PM |
Space Calendar - September 28, 2003 | Ron Baalke | History | 0 | September 28th 03 08:00 AM |
Space Calendar - August 28, 2003 | Ron Baalke | History | 0 | August 28th 03 05:32 PM |
Space Calendar - July 24, 2003 | Ron Baalke | History | 0 | July 24th 03 11:26 PM |