Results 1 to 2 of 2

Thread: Astronomical Unit (module) simple example for testing :)

  1. #1

    Astronomical Unit (module) simple example for testing

    although I have promised to go to christmas parties and to my family (they are shopping at the moment) I started last week this little exercise for (perhaps) a new module with some sense to use it for science. this first issue is hold very, very simple for using.

    Astronimical Units (Astronomische Einheit: ae) is a fixed value. but it's easy to make some calculations for it. the glossary about astronomical units (au) you find in the thinbasic script file and some links too.

    have fun with it. for next month I will check to make a gui for it with chance for user inputs.

    'test module for astronomische einheit (astronomical unit) by largo_winch, 21.12.2011
    'http://de.wikipedia.org/wiki/Astronomische_Einheit
    'http://neo.jpl.nasa.gov/glossary/au.html
    '    
    '1 Astronomical Unit = 149 598 000 kilometers / 149.597.870.691 Meter.    
    '
    '-------------->
    
    Uses "AstroUnit"
    
    MyFunction()  
    
    Function MyFunction()
      Dim ae1 As AstroUnit
      Dim ae2 As AstroUnit  
      Dim ae3 As AstroUnit  
      Dim ae4 As AstroUnit
      
      ae1 = New AstroUnit(1,1,1)
      ae2 = New AstroUnit(2,2,2)  
      ae3 = New AstroUnit(3,3,3)
      ae4 = New AstroUnit(4,4,4)
      
      MsgBox 0, ae1.ToString
      MsgBox 0, ae2.ToString  
      MsgBox 0, ae3.ToString  
      MsgBox 0, ae4.ToString
      
    End Function   
    
    '
    'Glossary:
    '
    '--------->
    'English:
    '--------->
    
    'ASTRONOMICAL UNIT (AU)
    
    ' 1 AU = 149,597,870.691 kilometers
    
    'Definition: An Astronomical Unit is approximately the mean distance Between 
    'the Earth And the Sun. It is a derived constant And used To 
    'indicate distances within the solar system. 
    'Its formal definition is the radius of an unperturbed 
    'circular orbit a massless body would revolve about 
    'the sun In 2*(Pi)/k days (i.e., 365.2568983.... days), 
    'where k is defined As the Gaussian constant 
    'exactly equal To 0.01720209895. 
    
    'Since an AU is based On radius of a circular orbit, 
    'one AU is actually slightly less than the average distance 
    'Between the Earth And the Sun (approximately 150 million km Or 93 million miles).
    
    'Historical Background: Tycho Brahe estimated the distance Between the 
    'Sun And the Earth At 8 million kilometers (5 million miles). 
    'Later, Johannes Kepler estimated the AU was At 24 million 
    'kilometers (15 million miles). In 1672, Giovanni Cassini made a much 
    'better estimate by Using Mars. By observing Mars from Paris 
    'And having a colleague, Jean Richer, also observe Mars At the 
    'same time In French Guiana In South America, Cassini determined 
    'the parallax of Mars. From that Cassini was able To calculate the 
    'distance from Earth To Mars, And Then the distance from Earth To the Sun. 
    'Cassini calculated the AU To be At 140 million kilometers (87 million miles), 
    'which is lower, but very close To the modern day Number. 
    
    '-------->
    'GERMAN:
    '-------->
    
    'Die AE war ursprünglich definiert als die Länge der 
    'großen Halbachse der Erdbahn.
    'Seit 1976 definiert die Internationale Astronomische Union (IAU) 
    'die AE als den Radius einer kreisförmigen Umlaufbahn, 
    'auf der ein Objekt mit vernachlässigbarer Masse und frei von Störungen 
    'die Sonne In 2? / k Tagen (also In etwa einem Jahr) umläuft.
    '[1] Dabei ist k die Gaußsche Gravitationskonstante, deren Wert 
    'In Astronomischen Maßeinheiten definitionsgemäß exakt k = 0,017 202 098 95 beträgt.
    
    'Die AE beträgt 149.597.870.691 Meter.    
    
    'Der moderne Wert wurde mittels Radar- und anderen Distanzmessungen 
    'von der Erde zu den Nachbarplaneten und zu Raumsonden bestimmt. 
    'Früher wurde die AE hauptsächlich aus feinsten Winkelmessungen (Parallaxen) 
    'abgeleitet, die zwischen weit entfernten Sternwarten zum Planeten Venus 
    'und zu erdnahen Asteroiden gemessen wurden.      
    '----------------------------------------------> FINE
    
    new edit: in zip file you will find a german and an english version and source code of powerbasic "thinbasic_astroUnit.bas" example


    2) @eros/petr/developer guys

    in "thincore.inc" file there is a declaration like

      DECLARE FUNCTION  thinBasic_Parse1Number                LIB "thinCore.DLL" ALIAS "thinBasic_Parse1Number"               () AS EXT
      DECLARE FUNCTION  thinBasic_Parse2Numbers               LIB "thinCore.DLL" ALIAS "thinBasic_Parse2Numbers"              (Num1 AS EXT, Num2 AS EXT) AS EXT
    

    but for "thinbasic_Parse1Number" (this function I wanted to choose, but didn't work as expected) it's better to use for future

     
    thinBasic_Parse1Numbers              (Num1 AS EXT) AS EXT
    
    so you can use and parse this number. in "thincore.inc" I guess it's not correct. without using one parsing number that's line is correct I am thinking:

    thinBasic_ParseNumber              () AS EXT
    

    bye, largo
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by largo_winch; 22-12-2011 at 18:49.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hi Largo,

    thanks for your post. I've checked your source code and saw you perfectly used new Module classes.
    I'm very happy about that and I can see there will be many many improvements in next thinBasic version on this side.

    The main difference between thinBasic_ParseNumber and thinBasic_Parse1Number is that
    1. thinBasic_ParseNumber only parse a numeric expression so if you have to parse a single numeric function parameter you also need to parse open and close parenthesis ()
    2. thinBasic_Parse1Number not only parse a numeric expression but it also parse () if optionally present


    Also another important difference is that:
    1. thinBasic_ParseNumber is a SUB and accepts a BYREF Extended numeric variable so you cannot use thinBasic_ParseNumber directly
    2. thinBasic_Parse1Number is a FUNCTION and it doesn't need any passing variable but instead it returns the result of the numeric expression it has parsed and resolved. It can also be used directly as parameter of other functions.


    Example using thinBasic_ParseNumber parsing something like ... (NumericParam)
        Local pp      As Byte
        Local eNum    As Ext
        '---Optionally checks if there is a (
        pp = thinBasic_CheckOpenParens_Optional
        thinBasic_ParseNumber eNum
        if pp then thinBasic_CheckCloseParens_Mandatory
    
    Same example now using thinBasic_Parse1Number parsing something like ... (NumericParam)
        Local eNum    As Ext
        eNum = thinBasic_Parse1Number
    
    It depends on the situations what is better to use for the programmer.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. Simple unit for UDT list in ThinBASIC
    By Petr Schreiber in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 3
    Last Post: 10-07-2010, 21:21
  2. TBGL - please help with testing fonts
    By Petr Schreiber in forum TBGL General
    Replies: 3
    Last Post: 13-06-2009, 21:33
  3. SandBox Testing
    By ISAWHIM in forum Code
    Replies: 15
    Last Post: 12-10-2008, 11:12
  4. Help on testing some new future features
    By ErosOlmi in forum thinBasic vaporware
    Replies: 14
    Last Post: 14-08-2008, 17:58
  5. GCC module example: very very simple expression evaluator
    By ErosOlmi in forum Module SDK (GCC C /C++)
    Replies: 4
    Last Post: 15-09-2007, 21:30

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •