Astro.com astronomical / astrological calculations

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Astro.com astronomical / astrological calculations

Post by lizard »

This is based on the free programming interface of Astrodienst (Astro.com).
https://www.astro.com/swisseph/swephprg.htm?lang=g

Sources (sweph.zip for Windows and swe_unix_src_2.07.01.tar.gz for linux libs) are here:
http://www.astro.com/ftp/swisseph/?lang=g

The most important part is the header swephexp.h which i converted to FB with FBfrog:

Code: Select all

' swisseph.bi for FreeBasic 1.05
' Distributed under GNU public license version 2
' http://www.gnu.org/licenses/gpl-2.0.html

' C Originalheader from swephexp.h:
 
' **********************************************************************************
' $Header: /home/dieter/sweph/RCS/swephexp.h,v 1.75 2009/04/08 07:19:08 dieter Exp $
' SWISSEPH: exported definitions and constants 

' This file represents the standard application interface (API)
' to the Swiss Ephemeris.

' A C programmer needs only to include this file, and link his code
' with the SwissEph library.

' The function calls are documented in the Programmer's documentation,
' which is online in HTML format.

' Structure of this file:
' Public API definitions
' Internal developer's definitions
' Public API functions.

' Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
' Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland.  All rights reserved.
' **********************************************************************************

#pragma once

#Ifndef __swisseph_bi__
  #Define __swisseph_bi__
#endif

' build target must be Linux or Windows

#ifdef  __FB_UNIX__	
  #Define WXCALL Cdecl
  #include once "crt/linux/unistd.bi"
  #ifdef __FB_64BIT__
    #inclib "swe64"
  #Else
    #inclib "swe32"
  #EndIf
#Else
  #Define WXCALL StdCall
  #include once "win/wtypes.bi"
  #include once "win/objbase.bi"
  #include once "win/wincon.bi"
  #include once "win/winbase.bi"
  #include once "crt/io.bi"
  #include once "windows.bi"
  #ifdef __FB_64BIT__
    #inclib "swedll64"
  #Else
    #inclib "swedll32"
  #EndIf
#EndIf

#include once "crt/long.bi"
#include once "crt/math.bi"
#include once "crt/stdlib.bi"
#include once "crt/stdio.bi"
#include once "crt/limits.bi"
#include once "crt/string.bi"
#include once "crt/ctype.bi"

#if defined(__FB_DOS__) or defined(__FB_WIN32__)
	#include once "crt/malloc.bi"
#EndIf

extern "C"

#define _SWEPHEXP_INCLUDED
#define _SWEODEF_INCLUDED
const MY_TRUE = 1
const MY_FALSE = 0

#if defined(__FB_DARWIN__) or defined(__FB_WIN32__)
	#define TLS
#else
	#define TLS __thread
#endif

#ifdef __FB_UNIX__
	const MSDOS = MY_FALSE
	const HPUNIX = MY_TRUE
	#define _HPUX_SOURCE
	const UNIX_FS = MY_TRUE
#elseif defined(__FB_WIN32__)
	#undef MSDOS
	const MSDOS = MY_TRUE
	#define sleep(x) Sleep((x) * 1000)
	const MSDOS = MY_TRUE
#endif

#if defined(__FB_DOS__) or defined(__FB_WIN32__)
	#undef MSDOS
	const MSDOS = MY_TRUE
	const HPUNIX = MY_FALSE
	const INTEL_BYTE_ORDER = 1
	#define MS_C
	const UNIX_FS = MY_FALSE
#endif

#define INT_16
type int32 as clong
type uint32 as culong
type int16 as long
type REAL8 as double
type INT4 as clong
type UINT4 as culong
type AS_BOOL as long
type UINT2 as ulong
#define ABS4 labs

#if defined(__FB_DOS__) or defined(__FB_WIN32__)
	#define SIGALRM SIGINT
#endif

'const TRUE = 1  ' intrinsic
'const FALSE = 0 ' intrinsic
'ERR = -1  ' variable in fb
const OK = 0

#ifdef __FB_WIN32__
	type UCHAR as SWE_UCHAR
	type SWE_UCHAR as ubyte
#else
	type UCHAR as ubyte
#endif

'' TODO: #define UCP (UCHAR*)
'' TODO: #define SCP (char*)
#define ODEGREE_STRING !"\194\176"
const HUGE = 1.7E+308

' deleted underscore in M_PI
const MPI = 3.14159265358979323846
const AS_MAXCH = 256
const RADTODEG = 180.0 / MPI
const DEGTORAD = MPI / 180.0

type centisec as int32
type CS as centisec
type CSEC as centisec

const DEG = 360000
const DEG7_30 = 2700000
const DEG15 = 15 * DEG
const DEG24 = 24 * DEG
const DEG30 = 30 * DEG
const DEG60 = 60 * DEG
const DEG90 = 90 * DEG
const DEG120 = 120 * DEG
const DEG150 = 150 * DEG
const DEG180 = 180 * DEG
const DEG270 = 270 * DEG
const DEG360 = 360 * DEG
const CSTORAD = DEGTORAD / 360000.0
const RADTOCS = RADTODEG * 360000.0
const CS2DEG = 1.0 / 360000.0

#ifdef __FB_UNIX__
	#define BFILE_R_ACCESS "r"
	#define BFILE_RW_ACCESS "r+"
	#define BFILE_W_CREATE "w"
	#define BFILE_A_ACCESS "a+"
	#define FILE_R_ACCESS "r"
	#define FILE_RW_ACCESS "r+"
	#define FILE_W_CREATE "w"
	#define FILE_A_ACCESS "a+"
	const O_BINARY = 0
#else
	#define BFILE_R_ACCESS "rb"
	#define BFILE_RW_ACCESS "r+b"
	#define BFILE_W_CREATE "wb"
	#define BFILE_A_ACCESS "a+b"
	#define PATH_SEPARATOR ";"
#endif

const OPEN_MODE = &o666

#ifdef __FB_UNIX__
	#define DIR_GLUE "/"
	#define PATH_SEPARATOR ";:"
#else
	#define FILE_R_ACCESS "rt"
	#define FILE_RW_ACCESS "r+t"
	#define FILE_W_CREATE "wt"
	#define FILE_A_ACCESS "a+t"
	#define DIR_GLUE !"\\"
#endif

const SE_AUNIT_TO_KM = 149597870.691
const SE_AUNIT_TO_LIGHTYEAR = 1.0 / 63241.077088071
const SE_AUNIT_TO_PARSEC = 1.0 / 206264.8062471
const SE_JUL_CAL = 0
const SE_GREG_CAL = 1
const SE_ECL_NUT = -1
const SE_SUN = 0
const SE_MOON = 1
const SE_MERCURY = 2
const SE_VENUS = 3
const SE_MARS = 4
const SE_JUPITER = 5
const SE_SATURN = 6
const SE_URANUS = 7
const SE_NEPTUNE = 8
const SE_PLUTO = 9
const SE_MEAN_NODE = 10
const SE_TRUE_NODE = 11
const SE_MEAN_APOG = 12
const SE_OSCU_APOG = 13
const SE_EARTH = 14
const SE_CHIRON = 15
const SE_PHOLUS = 16
const SE_CERES = 17
const SE_PALLAS = 18
const SE_JUNO = 19
const SE_VESTA = 20
const SE_INTP_APOG = 21
const SE_INTP_PERG = 22
const SE_NPLANETS = 23
const SE_AST_OFFSET = 10000
const SE_VARUNA = SE_AST_OFFSET + 20000
const SE_FICT_OFFSET = 40
const SE_FICT_OFFSET_1 = 39
const SE_FICT_MAX = 999
const SE_NFICT_ELEM = 15
const SE_COMET_OFFSET = 1000
const SE_NALL_NAT_POINTS = SE_NPLANETS + SE_NFICT_ELEM
const SE_CUPIDO = 40
const SE_HADES = 41
const SE_ZEUS = 42
const SE_KRONOS = 43
const SE_APOLLON = 44
const SE_ADMETOS = 45
const SE_VULKANUS = 46
const SE_POSEIDON = 47
const SE_ISIS = 48
const SE_NIBIRU = 49
const SE_HARRINGTON = 50
const SE_NEPTUNE_LEVERRIER = 51
const SE_NEPTUNE_ADAMS = 52
const SE_PLUTO_LOWELL = 53
const SE_PLUTO_PICKERING = 54
const SE_VULCAN = 55
const SE_WHITE_MOON = 56
const SE_PROSERPINA = 57
const SE_WALDEMATH = 58
const SE_FIXSTAR = -10
const SE_ASC = 0
const SE_MC = 1
const SE_ARMC = 2
const SE_VERTEX = 3
const SE_EQUASC = 4
const SE_COASC1 = 5
const SE_COASC2 = 6
const SE_POLASC = 7
const SE_NASCMC = 8
const SEFLG_JPLEPH = 1
const SEFLG_SWIEPH = 2
const SEFLG_MOSEPH = 4
const SEFLG_HELCTR = 8
const SEFLG_TRUEPOS = 16
const SEFLG_J2000 = 32
const SEFLG_NONUT = 64
const SEFLG_SPEED3 = 128
const SEFLG_SPEED = 256
const SEFLG_NOGDEFL = 512
const SEFLG_NOABERR = 1024
const SEFLG_ASTROMETRIC = SEFLG_NOABERR or SEFLG_NOGDEFL
const SEFLG_EQUATORIAL = 2 * 1024
const SEFLG_XYZ = 4 * 1024
const SEFLG_RADIANS = 8 * 1024
const SEFLG_BARYCTR = 16 * 1024
const SEFLG_TOPOCTR = 32 * 1024
const SEFLG_ORBEL_AA = SEFLG_TOPOCTR
const SEFLG_SIDEREAL = 64 * 1024
const SEFLG_ICRS = 128 * 1024
const SEFLG_DPSIDEPS_1980 = 256 * 1024
const SEFLG_JPLHOR = SEFLG_DPSIDEPS_1980
const SEFLG_JPLHOR_APPROX = 512 * 1024
const SE_SIDBITS = 256
const SE_SIDBIT_ECL_T0 = 256
const SE_SIDBIT_SSY_PLANE = 512
const SE_SIDBIT_USER_UT = 1024
const SE_SIDM_FAGAN_BRADLEY = 0
const SE_SIDM_LAHIRI = 1
const SE_SIDM_DELUCE = 2
const SE_SIDM_RAMAN = 3
const SE_SIDM_USHASHASHI = 4
const SE_SIDM_KRISHNAMURTI = 5
const SE_SIDM_DJWHAL_KHUL = 6
const SE_SIDM_YUKTESHWAR = 7
const SE_SIDM_JN_BHASIN = 8
const SE_SIDM_BABYL_KUGLER1 = 9
const SE_SIDM_BABYL_KUGLER2 = 10
const SE_SIDM_BABYL_KUGLER3 = 11
const SE_SIDM_BABYL_HUBER = 12
const SE_SIDM_BABYL_ETPSC = 13
const SE_SIDM_ALDEBARAN_15TAU = 14
const SE_SIDM_HIPPARCHOS = 15
const SE_SIDM_SASSANIAN = 16
const SE_SIDM_GALCENT_0SAG = 17
const SE_SIDM_J2000 = 18
const SE_SIDM_J1900 = 19
const SE_SIDM_B1950 = 20
const SE_SIDM_SURYASIDDHANTA = 21
const SE_SIDM_SURYASIDDHANTA_MSUN = 22
const SE_SIDM_ARYABHATA = 23
const SE_SIDM_ARYABHATA_MSUN = 24
const SE_SIDM_SS_REVATI = 25
const SE_SIDM_SS_CITRA = 26
const SE_SIDM_TRUE_CITRA = 27
const SE_SIDM_TRUE_REVATI = 28
const SE_SIDM_TRUE_PUSHYA = 29
const SE_SIDM_GALCENT_RGILBRAND = 30
const SE_SIDM_GALEQU_IAU1958 = 31
const SE_SIDM_GALEQU_TRUE = 32
const SE_SIDM_GALEQU_MULA = 33
const SE_SIDM_GALALIGN_MARDYKS = 34
const SE_SIDM_TRUE_MULA = 35
const SE_SIDM_GALCENT_MULA_WILHELM = 36
const SE_SIDM_ARYABHATA_522 = 37
const SE_SIDM_BABYL_BRITTON = 38
const SE_SIDM_TRUE_SHEORAN = 39
const SE_SIDM_USER = 255
const SE_NSIDM_PREDEF = 40
const SE_NODBIT_MEAN = 1
const SE_NODBIT_OSCU = 2
const SE_NODBIT_OSCU_BAR = 4
const SE_NODBIT_FOPOINT = 256
const SEFLG_DEFAULTEPH = SEFLG_SWIEPH
const SE_MAX_STNAME = 256
const SE_ECL_CENTRAL = 1
const SE_ECL_NONCENTRAL = 2
const SE_ECL_TOTAL = 4
const SE_ECL_ANNULAR = 8
const SE_ECL_PARTIAL = 16
const SE_ECL_ANNULAR_TOTAL = 32
const SE_ECL_PENUMBRAL = 64
const SE_ECL_ALLTYPES_SOLAR = ((((SE_ECL_CENTRAL or SE_ECL_NONCENTRAL) or SE_ECL_TOTAL) or SE_ECL_ANNULAR) or SE_ECL_PARTIAL) or SE_ECL_ANNULAR_TOTAL
const SE_ECL_ALLTYPES_LUNAR = (SE_ECL_TOTAL or SE_ECL_PARTIAL) or SE_ECL_PENUMBRAL
const SE_ECL_VISIBLE = 128
const SE_ECL_MAX_VISIBLE = 256
const SE_ECL_1ST_VISIBLE = 512
const SE_ECL_PARTBEG_VISIBLE = 512
const SE_ECL_2ND_VISIBLE = 1024
const SE_ECL_TOTBEG_VISIBLE = 1024
const SE_ECL_3RD_VISIBLE = 2048
const SE_ECL_TOTEND_VISIBLE = 2048
const SE_ECL_4TH_VISIBLE = 4096
const SE_ECL_PARTEND_VISIBLE = 4096
const SE_ECL_PENUMBBEG_VISIBLE = 8192
const SE_ECL_PENUMBEND_VISIBLE = 16384
const SE_ECL_OCC_BEG_DAYLIGHT = 8192
const SE_ECL_OCC_END_DAYLIGHT = 16384
const SE_ECL_ONE_TRY = 32 * 1024
const SE_CALC_RISE = 1
const SE_CALC_SET = 2
const SE_CALC_MTRANSIT = 4
const SE_CALC_ITRANSIT = 8
const SE_BIT_DISC_CENTER = 256
const SE_BIT_DISC_BOTTOM = 8192
const SE_BIT_GEOCTR_NO_ECL_LAT = 128
const SE_BIT_NO_REFRACTION = 512
const SE_BIT_CIVIL_TWILIGHT = 1024
const SE_BIT_NAUTIC_TWILIGHT = 2048
const SE_BIT_ASTRO_TWILIGHT = 4096
const SE_BIT_FIXED_DISC_SIZE = 16384
const SE_BIT_FORCE_SLOW_METHOD = 32768
const SE_BIT_HINDU_RISING = (SE_BIT_DISC_CENTER or SE_BIT_NO_REFRACTION) or SE_BIT_GEOCTR_NO_ECL_LAT
const SE_ECL2HOR = 0
const SE_EQU2HOR = 1
const SE_HOR2ECL = 0
const SE_HOR2EQU = 1
const SE_TRUE_TO_APP = 0
const SE_APP_TO_TRUE = 1
const SE_DE_NUMBER = 431
#define SE_FNAME_DE200 "de200.eph"
#define SE_FNAME_DE403 "de403.eph"
#define SE_FNAME_DE404 "de404.eph"
#define SE_FNAME_DE405 "de405.eph"
#define SE_FNAME_DE406 "de406.eph"
#define SE_FNAME_DE431 "de431.eph"
#define SE_FNAME_DFT SE_FNAME_DE431
#define SE_FNAME_DFT2 SE_FNAME_DE406
#define SE_STARFILE_OLD "fixstars.cat"
#define SE_STARFILE "sefstars.txt"
#define SE_ASTNAMFILE "seasnam.txt"
#define SE_FICTFILE "seorbel.txt"

#ifdef __FB_UNIX__
	#define SE_EPHE_PATH ".:/users/ephe2/:/users/ephe/"
#else
	#define SE_EPHE_PATH !"\\sweph\\ephe\\"
#endif

const SE_SPLIT_DEG_ROUND_SEC = 1
const SE_SPLIT_DEG_ROUND_MIN = 2
const SE_SPLIT_DEG_ROUND_DEG = 4
const SE_SPLIT_DEG_ZODIACAL = 8
const SE_SPLIT_DEG_NAKSHATRA = 1024
const SE_SPLIT_DEG_KEEP_SIGN = 16
const SE_SPLIT_DEG_KEEP_DEG = 32
const SE_HELIACAL_RISING = 1
const SE_HELIACAL_SETTING = 2
const SE_MORNING_FIRST = SE_HELIACAL_RISING
const SE_EVENING_LAST = SE_HELIACAL_SETTING
const SE_EVENING_FIRST = 3
const SE_MORNING_LAST = 4
const SE_ACRONYCHAL_RISING = 5
const SE_ACRONYCHAL_SETTING = 6
const SE_COSMICAL_SETTING = SE_ACRONYCHAL_SETTING
const SE_HELFLAG_LONG_SEARCH = 128
const SE_HELFLAG_HIGH_PRECISION = 256
const SE_HELFLAG_OPTICAL_PARAMS = 512
const SE_HELFLAG_NO_DETAILS = 1024
const SE_HELFLAG_SEARCH_1_PERIOD = 1 shl 11
const SE_HELFLAG_VISLIM_DARK = 1 shl 12
const SE_HELFLAG_VISLIM_NOMOON = 1 shl 13
const SE_HELFLAG_VISLIM_PHOTOPIC = 1 shl 14
const SE_HELFLAG_VISLIM_SCOTOPIC = 1 shl 15
const SE_HELFLAG_AV = 1 shl 16
const SE_HELFLAG_AVKIND_VR = 1 shl 16
const SE_HELFLAG_AVKIND_PTO = 1 shl 17
const SE_HELFLAG_AVKIND_MIN7 = 1 shl 18
const SE_HELFLAG_AVKIND_MIN9 = 1 shl 19
const SE_HELFLAG_AVKIND = ((SE_HELFLAG_AVKIND_VR or SE_HELFLAG_AVKIND_PTO) or SE_HELFLAG_AVKIND_MIN7) or SE_HELFLAG_AVKIND_MIN9
const TJD_INVALID = 99999999.0
const SIMULATE_VICTORVB = 1
const SE_PHOTOPIC_FLAG = 0
const SE_SCOTOPIC_FLAG = 1
const SE_MIXEDOPIC_FLAG = 2
const SE_TIDAL_DE200 = -23.8946
const SE_TIDAL_DE403 = -25.580
const SE_TIDAL_DE404 = -25.580
const SE_TIDAL_DE405 = -25.826
const SE_TIDAL_DE406 = -25.826
const SE_TIDAL_DE421 = -25.85
const SE_TIDAL_DE422 = -25.85
const SE_TIDAL_DE430 = -25.82
const SE_TIDAL_DE431 = -25.80
const SE_TIDAL_26 = -26.0
const SE_TIDAL_STEPHENSON_2016 = -25.85
const SE_TIDAL_DEFAULT = SE_TIDAL_DE431
const SE_TIDAL_AUTOMATIC = 999999
const SE_TIDAL_MOSEPH = SE_TIDAL_DE404
const SE_TIDAL_SWIEPH = SE_TIDAL_DEFAULT
const SE_TIDAL_JPLEPH = SE_TIDAL_DEFAULT
const SE_DELTAT_AUTOMATIC = -1E-10
const SE_MODEL_DELTAT = 0
const SE_MODEL_PREC_LONGTERM = 1
const SE_MODEL_PREC_SHORTTERM = 2
const SE_MODEL_NUT = 3
const SE_MODEL_BIAS = 4
const SE_MODEL_JPLHOR_MODE = 5
const SE_MODEL_JPLHORA_MODE = 6
const SE_MODEL_SIDT = 7
const NSE_MODELS = 8
const SEMOD_NPREC = 10
const SEMOD_PREC_IAU_1976 = 1
const SEMOD_PREC_LASKAR_1986 = 2
const SEMOD_PREC_WILL_EPS_LASK = 3
const SEMOD_PREC_WILLIAMS_1994 = 4
const SEMOD_PREC_SIMON_1994 = 5
const SEMOD_PREC_IAU_2000 = 6
const SEMOD_PREC_BRETAGNON_2003 = 7
const SEMOD_PREC_IAU_2006 = 8
const SEMOD_PREC_VONDRAK_2011 = 9
const SEMOD_PREC_OWEN_1990 = 10
const SEMOD_PREC_DEFAULT = SEMOD_PREC_VONDRAK_2011
const SEMOD_PREC_DEFAULT_SHORT = SEMOD_PREC_VONDRAK_2011
const SEMOD_NNUT = 4
const SEMOD_NUT_IAU_1980 = 1
const SEMOD_NUT_IAU_CORR_1987 = 2
const SEMOD_NUT_IAU_2000A = 3
const SEMOD_NUT_IAU_2000B = 4
const SEMOD_NUT_DEFAULT = SEMOD_NUT_IAU_2000B
const SEMOD_NSIDT = 4
const SEMOD_SIDT_IAU_1976 = 1
const SEMOD_SIDT_IAU_2006 = 2
const SEMOD_SIDT_IERS_CONV_2010 = 3
const SEMOD_SIDT_LONGTERM = 4
const SEMOD_SIDT_DEFAULT = SEMOD_SIDT_LONGTERM
const SEMOD_NBIAS = 3
const SEMOD_BIAS_NONE = 1
const SEMOD_BIAS_IAU2000 = 2
const SEMOD_BIAS_IAU2006 = 3
const SEMOD_BIAS_DEFAULT = SEMOD_BIAS_IAU2006
const SEMOD_NJPLHOR = 2
const SEMOD_JPLHOR_LONG_AGREEMENT = 1
const SEMOD_JPLHOR_DEFAULT = SEMOD_JPLHOR_LONG_AGREEMENT
const SEMOD_NJPLHORA = 3
const SEMOD_JPLHORA_1 = 1
const SEMOD_JPLHORA_2 = 2
const SEMOD_JPLHORA_3 = 3
const SEMOD_JPLHORA_DEFAULT = SEMOD_JPLHORA_3
const SEMOD_NDELTAT = 5
const SEMOD_DELTAT_STEPHENSON_MORRISON_1984 = 1
const SEMOD_DELTAT_STEPHENSON_1997 = 2
const SEMOD_DELTAT_STEPHENSON_MORRISON_2004 = 3
const SEMOD_DELTAT_ESPENAK_MEEUS_2006 = 4
const SEMOD_DELTAT_STEPHENSON_ETC_2016 = 5
const SEMOD_DELTAT_DEFAULT = SEMOD_DELTAT_STEPHENSON_ETC_2016

' not sure this works as expected
'#define MALLOC allocate  
'#define CALLOC callocate
'#define FREE deallocate

'#ifdef __FB_DOS__
	'#define MALLOC _fmalloc
	'#define CALLOC _fcalloc
	'#define FREE _ffree
'#else
	'#define MALLOC malloc 
	'#define CALLOC calloc 
	'#define FREE free    
'#endif

#define CALL_CONV
#define EXP16
#define EXP32
'' TODO: #define ext_def(x) extern EXP32 x CALL_CONV EXP16

declare function swe_heliacal_ut(byval tjdstart_ut as double, byval geopos as double ptr, byval datm as double ptr, byval dobs as double ptr, byval ObjectName as zstring ptr, byval TypeEvent as int32, byval iflag as int32, byval dret as double ptr, byval serr as zstring ptr) as int32
declare function swe_heliacal_pheno_ut(byval tjd_ut as double, byval geopos as double ptr, byval datm as double ptr, byval dobs as double ptr, byval ObjectName as zstring ptr, byval TypeEvent as int32, byval helflag as int32, byval darr as double ptr, byval serr as zstring ptr) as int32
declare function swe_vis_limit_mag(byval tjdut as double, byval geopos as double ptr, byval datm as double ptr, byval dobs as double ptr, byval ObjectName as zstring ptr, byval helflag as int32, byval dret as double ptr, byval serr as zstring ptr) as int32
declare function swe_heliacal_angle(byval tjdut as double, byval dgeo as double ptr, byval datm as double ptr, byval dobs as double ptr, byval helflag as int32, byval mag as double, byval azi_obj as double, byval azi_sun as double, byval azi_moon as double, byval alt_moon as double, byval dret as double ptr, byval serr as zstring ptr) as int32
declare function swe_topo_arcus_visionis(byval tjdut as double, byval dgeo as double ptr, byval datm as double ptr, byval dobs as double ptr, byval helflag as int32, byval mag as double, byval azi_obj as double, byval alt_obj as double, byval azi_sun as double, byval azi_moon as double, byval alt_moon as double, byval dret as double ptr, byval serr as zstring ptr) as int32
declare sub swe_set_astro_models(byval samod as zstring ptr, byval iflag as int32)
declare sub swe_get_astro_models(byval samod as zstring ptr, byval sdet as zstring ptr, byval iflag as int32)
declare function swe_version(byval as zstring ptr) as zstring ptr
declare function swe_get_library_path(byval as zstring ptr) as zstring ptr
declare function swe_calc(byval tjd as double, byval ipl as long, byval iflag as int32, byval xx as double ptr, byval serr as zstring ptr) as int32
declare function swe_calc_ut(byval tjd_ut as double, byval ipl as int32, byval iflag as int32, byval xx as double ptr, byval serr as zstring ptr) as int32
declare function swe_fixstar(byval star as zstring ptr, byval tjd as double, byval iflag as int32, byval xx as double ptr, byval serr as zstring ptr) as int32
declare function swe_fixstar_ut(byval star as zstring ptr, byval tjd_ut as double, byval iflag as int32, byval xx as double ptr, byval serr as zstring ptr) as int32
declare function swe_fixstar_mag(byval star as zstring ptr, byval mag as double ptr, byval serr as zstring ptr) as int32
declare function swe_fixstar2(byval star as zstring ptr, byval tjd as double, byval iflag as int32, byval xx as double ptr, byval serr as zstring ptr) as int32
declare function swe_fixstar2_ut(byval star as zstring ptr, byval tjd_ut as double, byval iflag as int32, byval xx as double ptr, byval serr as zstring ptr) as int32
declare function swe_fixstar2_mag(byval star as zstring ptr, byval mag as double ptr, byval serr as zstring ptr) as int32
declare sub swe_close()
declare sub swe_set_ephe_path(byval path as zstring ptr)
declare sub swe_set_jpl_file(byval fname as zstring ptr)
declare function swe_get_planet_name(byval ipl as long, byval spname as zstring ptr) as zstring ptr
declare sub swe_set_topo(byval geolon as double, byval geolat as double, byval geoalt as double)
declare sub swe_set_sid_mode(byval sid_mode as int32, byval t0 as double, byval ayan_t0 as double)
declare function swe_get_ayanamsa_ex(byval tjd_et as double, byval iflag as int32, byval daya as double ptr, byval serr as zstring ptr) as int32
declare function swe_get_ayanamsa_ex_ut(byval tjd_ut as double, byval iflag as int32, byval daya as double ptr, byval serr as zstring ptr) as int32
declare function swe_get_ayanamsa(byval tjd_et as double) as double
declare function swe_get_ayanamsa_ut(byval tjd_ut as double) as double
declare function swe_get_ayanamsa_name(byval isidmode as int32) as const zstring ptr
declare function swe_date_conversion(byval y as long, byval m as long, byval d as long, byval utime as double, byval c as byte, byval tjd as double ptr) as long
declare function swe_julday(byval year as long, byval month as long, byval day as long, byval hour as double, byval gregflag as long) as double
declare sub swe_revjul(byval jd as double, byval gregflag as long, byval jyear as long ptr, byval jmon as long ptr, byval jday as long ptr, byval jut as double ptr)
declare function swe_utc_to_jd(byval iyear as int32, byval imonth as int32, byval iday as int32, byval ihour as int32, byval imin as int32, byval dsec as double, byval gregflag as int32, byval dret as double ptr, byval serr as zstring ptr) as int32
declare sub swe_jdet_to_utc(byval tjd_et as double, byval gregflag as int32, byval iyear as int32 ptr, byval imonth as int32 ptr, byval iday as int32 ptr, byval ihour as int32 ptr, byval imin as int32 ptr, byval dsec as double ptr)
declare sub swe_jdut1_to_utc(byval tjd_ut as double, byval gregflag as int32, byval iyear as int32 ptr, byval imonth as int32 ptr, byval iday as int32 ptr, byval ihour as int32 ptr, byval imin as int32 ptr, byval dsec as double ptr)
declare sub swe_utc_time_zone(byval iyear as int32, byval imonth as int32, byval iday as int32, byval ihour as int32, byval imin as int32, byval dsec as double, byval d_timezone as double, byval iyear_out as int32 ptr, byval imonth_out as int32 ptr, byval iday_out as int32 ptr, byval ihour_out as int32 ptr, byval imin_out as int32 ptr, byval dsec_out as double ptr)
declare function swe_houses(byval tjd_ut as double, byval geolat as double, byval geolon as double, byval hsys as long, byval cusps as double ptr, byval ascmc as double ptr) as long
declare function swe_houses_ex(byval tjd_ut as double, byval iflag as int32, byval geolat as double, byval geolon as double, byval hsys as long, byval cusps as double ptr, byval ascmc as double ptr) as long
declare function swe_houses_armc(byval armc as double, byval geolat as double, byval eps as double, byval hsys as long, byval cusps as double ptr, byval ascmc as double ptr) as long
declare function swe_house_pos(byval armc as double, byval geolat as double, byval eps as double, byval hsys as long, byval xpin as double ptr, byval serr as zstring ptr) as double
declare function swe_house_name(byval hsys as long) as zstring ptr
declare function swe_gauquelin_sector(byval t_ut as double, byval ipl as int32, byval starname as zstring ptr, byval iflag as int32, byval imeth as int32, byval geopos as double ptr, byval atpress as double, byval attemp as double, byval dgsect as double ptr, byval serr as zstring ptr) as int32
declare function swe_sol_eclipse_where(byval tjd as double, byval ifl as int32, byval geopos as double ptr, byval attr as double ptr, byval serr as zstring ptr) as int32
declare function swe_lun_occult_where(byval tjd as double, byval ipl as int32, byval starname as zstring ptr, byval ifl as int32, byval geopos as double ptr, byval attr as double ptr, byval serr as zstring ptr) as int32
declare function swe_sol_eclipse_how(byval tjd as double, byval ifl as int32, byval geopos as double ptr, byval attr as double ptr, byval serr as zstring ptr) as int32
declare function swe_sol_eclipse_when_loc(byval tjd_start as double, byval ifl as int32, byval geopos as double ptr, byval tret as double ptr, byval attr as double ptr, byval backward as int32, byval serr as zstring ptr) as int32
declare function swe_lun_occult_when_loc(byval tjd_start as double, byval ipl as int32, byval starname as zstring ptr, byval ifl as int32, byval geopos as double ptr, byval tret as double ptr, byval attr as double ptr, byval backward as int32, byval serr as zstring ptr) as int32
declare function swe_sol_eclipse_when_glob(byval tjd_start as double, byval ifl as int32, byval ifltype as int32, byval tret as double ptr, byval backward as int32, byval serr as zstring ptr) as int32
declare function swe_lun_occult_when_glob(byval tjd_start as double, byval ipl as int32, byval starname as zstring ptr, byval ifl as int32, byval ifltype as int32, byval tret as double ptr, byval backward as int32, byval serr as zstring ptr) as int32
declare function swe_lun_eclipse_how(byval tjd_ut as double, byval ifl as int32, byval geopos as double ptr, byval attr as double ptr, byval serr as zstring ptr) as int32
declare function swe_lun_eclipse_when(byval tjd_start as double, byval ifl as int32, byval ifltype as int32, byval tret as double ptr, byval backward as int32, byval serr as zstring ptr) as int32
declare function swe_lun_eclipse_when_loc(byval tjd_start as double, byval ifl as int32, byval geopos as double ptr, byval tret as double ptr, byval attr as double ptr, byval backward as int32, byval serr as zstring ptr) as int32
declare function swe_pheno(byval tjd as double, byval ipl as int32, byval iflag as int32, byval attr as double ptr, byval serr as zstring ptr) as int32
declare function swe_pheno_ut(byval tjd_ut as double, byval ipl as int32, byval iflag as int32, byval attr as double ptr, byval serr as zstring ptr) as int32
declare function swe_refrac(byval inalt as double, byval atpress as double, byval attemp as double, byval calc_flag as int32) as double
declare function swe_refrac_extended(byval inalt as double, byval geoalt as double, byval atpress as double, byval attemp as double, byval lapse_rate as double, byval calc_flag as int32, byval dret as double ptr) as double
declare sub swe_set_lapse_rate(byval lapse_rate as double)
declare sub swe_azalt(byval tjd_ut as double, byval calc_flag as int32, byval geopos as double ptr, byval atpress as double, byval attemp as double, byval xin as double ptr, byval xaz as double ptr)
declare sub swe_azalt_rev(byval tjd_ut as double, byval calc_flag as int32, byval geopos as double ptr, byval xin as double ptr, byval xout as double ptr)
declare function swe_rise_trans_true_hor(byval tjd_ut as double, byval ipl as int32, byval starname as zstring ptr, byval epheflag as int32, byval rsmi as int32, byval geopos as double ptr, byval atpress as double, byval attemp as double, byval horhgt as double, byval tret as double ptr, byval serr as zstring ptr) as int32
declare function swe_rise_trans(byval tjd_ut as double, byval ipl as int32, byval starname as zstring ptr, byval epheflag as int32, byval rsmi as int32, byval geopos as double ptr, byval atpress as double, byval attemp as double, byval tret as double ptr, byval serr as zstring ptr) as int32
declare function swe_nod_aps(byval tjd_et as double, byval ipl as int32, byval iflag as int32, byval method as int32, byval xnasc as double ptr, byval xndsc as double ptr, byval xperi as double ptr, byval xaphe as double ptr, byval serr as zstring ptr) as int32
declare function swe_nod_aps_ut(byval tjd_ut as double, byval ipl as int32, byval iflag as int32, byval method as int32, byval xnasc as double ptr, byval xndsc as double ptr, byval xperi as double ptr, byval xaphe as double ptr, byval serr as zstring ptr) as int32
declare function swe_get_orbital_elements(byval tjd_et as double, byval ipl as int32, byval iflag as int32, byval dret as double ptr, byval serr as zstring ptr) as int32
declare function swe_orbit_max_min_true_distance(byval tjd_et as double, byval ipl as int32, byval iflag as int32, byval dmax as double ptr, byval dmin as double ptr, byval dtrue as double ptr, byval serr as zstring ptr) as int32
declare function swe_deltat(byval tjd as double) as double
declare function swe_deltat_ex(byval tjd as double, byval iflag as int32, byval serr as zstring ptr) as double
declare function swe_time_equ(byval tjd as double, byval te as double ptr, byval serr as zstring ptr) as int32
declare function swe_lmt_to_lat(byval tjd_lmt as double, byval geolon as double, byval tjd_lat as double ptr, byval serr as zstring ptr) as int32
declare function swe_lat_to_lmt(byval tjd_lat as double, byval geolon as double, byval tjd_lmt as double ptr, byval serr as zstring ptr) as int32
declare function swe_sidtime0(byval tjd_ut as double, byval eps as double, byval nut as double) as double
declare function swe_sidtime(byval tjd_ut as double) as double
declare sub swe_set_interpolate_nut(byval do_interpolate as AS_BOOL)
declare sub swe_cotrans(byval xpo as double ptr, byval xpn as double ptr, byval eps as double)
declare sub swe_cotrans_sp(byval xpo as double ptr, byval xpn as double ptr, byval eps as double)
declare function swe_get_tid_acc() as double
declare sub swe_set_tid_acc(byval t_acc as double)
declare sub swe_set_delta_t_userdef(byval dt as double)
declare function swe_degnorm(byval x as double) as double
declare function swe_radnorm(byval x as double) as double
declare function swe_rad_midp(byval x1 as double, byval x0 as double) as double
declare function swe_deg_midp(byval x1 as double, byval x0 as double) as double
declare sub swe_split_deg(byval ddeg as double, byval roundflag as int32, byval ideg as int32 ptr, byval imin as int32 ptr, byval isec as int32 ptr, byval dsecfr as double ptr, byval isgn as int32 ptr)
declare function swe_csnorm(byval p as centisec) as centisec
declare function swe_difcsn(byval p1 as centisec, byval p2 as centisec) as centisec
declare function swe_difdegn(byval p1 as double, byval p2 as double) as double
declare function swe_difcs2n(byval p1 as centisec, byval p2 as centisec) as centisec
declare function swe_difdeg2n(byval p1 as double, byval p2 as double) as double
declare function swe_difrad2n(byval p1 as double, byval p2 as double) as double
declare function swe_csroundsec(byval x as centisec) as centisec
declare function swe_d2l(byval x as double) as int32
declare function swe_day_of_week(byval jd as double) as long
declare function swe_cs2timestr(byval t as centisec, byval sep as long, byval suppressZero as AS_BOOL, byval a as zstring ptr) as zstring ptr
declare function swe_cs2lonlatstr(byval t as centisec, byval pchar as byte, byval mchar as byte, byval s as zstring ptr) as zstring ptr
declare function swe_cs2degstr(byval t as centisec, byval a as zstring ptr) as zstring ptr

end extern

#EndIf ' __swisseph_bi__
edit: again a corrected version, now it should work on Linux and Windows
Last edited by lizard on May 27, 2018 5:40, edited 11 times in total.
Luis Babboni
Posts: 375
Joined: Mar 15, 2015 12:41

Re: Astro.com astronomical / astrological calculations

Post by Luis Babboni »

Sorry, is a program related with astronomy or with astrology? I do not know any relation between them. Thanks.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

Both. For astrology you need correct calculations. But the primary focus of astro.com is astrology.
Luis Babboni
Posts: 375
Joined: Mar 15, 2015 12:41

Re: Astro.com astronomical / astrological calculations

Post by Luis Babboni »

lizard wrote:Both. For astrology you need correct calculations. But the primary focus of astro.com is astrology.
OK. Thanks.
BTW, do astrology works? I know astronomy did, but not know astrology.
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by grindstone »

Luis Babboni wrote:BTW, do astrology works? I know astronomy did, but not know astrology.
It's quite simple: astronomy works always, astrology works sometimes. <grin>
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

Luis Babboni wrote:BTW, do astrology works? I know astronomy did, but not know astrology.
Both work. Like Sun, Moon and Planets move in circles the whole nature follows their rhythm. Thats pretty obvious.

But here is not the right place to discuss this. Who wants to use Swisseph in FB can do it now. :-)
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

For Windows go to the unpacked sweph.zip \bin and copy .dll and .lib files to the folder with swe_mini.bas and swisseph.bi.

For Linux in terminal go the directory where you downloaded "swe_unix_2.07.1" /src
and type:

make libswe.a
make libswe.so
and rename them after your current OS to libswe32.* or libswe64.*
and sudo cp libswe*.so /usr/lib

Now it should work.

Code: Select all

' swe_mini.bas	

' minimal program to test the Swiss Ephemeris

#include "swisseph.bi" 	

Dim Shared As long jyear = 2000
Dim Shared As short jday = 1, jmon = 1, p, iflag, iflgret
Dim Shared As double jut = 0.0, tjd, te, x2(6)
Dim shared As zstring * 10 svers
dim shared as zstring * 256 serr

dim as string planets(...) = {"Sun", "Moon ", "Mercury", "Venus", "Mars", _
"Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}

iflag = SEFLG_SPEED
	    
' we have day, month and year and convert to Julian day number
tjd = swe_julday(jyear,jmon,jday,jut,SE_GREG_CAL)      
	    
' compute Ephemeris time from Universal time by adding delta_t
te = tjd + swe_deltat(tjd)

screenres 1024,768,32
width 1024/8, 768/16

print
print "Date (at 0:00 Universal time):", jday, jmon, jyear
print
print "Planet         Longitude                   Latitude                    Distance                    Speed"
print
    
' loop over all planets    
for p = SE_SUN to SE_PLUTO 
  iflgret = swe_calc(te, p, iflag, @x2(0), serr)
	      
' if there is a problem, a negative value is returned and a 
' message is in serr       
  if iflgret < 0 then print "Error: ", serr   
	      
' print the coordinates     
  print planets(p), x2(0), x2(1), x2(2), x2(3)   
next
  
' get version
swe_version(svers)
print
print "Swiss Ephemeris V " & svers

swe_close()

Sleep
Changed the integers and zstring. Improved appearance with Screenres.
Last edited by lizard on May 18, 2018 17:27, edited 10 times in total.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

Inserted the following in above listing swephexp.bi:

Code: Select all

' build target must be Windows or Linux

#ifdef __FB_64BIT__
  #ifdef __FB_LINUX__
    #inclib "swe64"
  #else 
    #inclib "swedll64"
  #endif
#else
  #ifdef  __FB_LINUX__
    #inclib "swe32"
  #else
    #inclib "swedll32"
  #endif
#endif
Tested with Linux 32 bit and 64 bit. Any help will be welcome.
Luis Babboni
Posts: 375
Joined: Mar 15, 2015 12:41

Re: Astro.com astronomical / astrological calculations

Post by Luis Babboni »

grindstone wrote:
Luis Babboni wrote:BTW, do astrology works? I know astronomy did, but not know astrology.
It's quite simple: astronomy works always, astrology works sometimes. <grin>
:-D
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

For Linux in terminal go the directory where you downloaded "/Downloads/swe_unix_2.07.1/src"
and type:

make libswe.a
make libswe.so
and rename them after your current OS to libswe32.* or libswe64.*
This may look strange at first, but linux compiles the same sourcefiles in the makefile to different sizes in 32 and 64 bit (output shortened to show only the blocks and name)

Code: Select all

ls -s -l *.so 

1288   libswe32.so
 960   libswe64.so

ls -s -l *.dll

 604  swedll32.dll
 712  swedll64.dll
In linux the 32 bit version is bigger, in windows the 64 bit is bigger. The linux 64 bit version don`t work in 32 bit OS (tested).

The integers in swe_mini.bas are working in both here.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

Anyway, i switched to the usage of short and long, avoiding integer mostly. This results in a new swe_mini.bas which compiles just the same. I pasted above.

And changed the library name to the more speaking "swisseph.bi".

Improved appearance of swe_mini.bas with screenres.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

Remembering tested another astronomy library in c years ago i found swisseph is much better. In my opinion it is #1 in the world.

It has three models for calculating:

1 JPL is the exactest with long files based of data directly from NASA

2. Swiss ephemeris is the normal with separate data files

3. Moshier is without extra files (fallback)

With these models it is currently possible to calculate over 58 000 planetoids (see seasnam.txt) and hundreds of stars (see sefstars.txt). And many astronomical events like eclipses and such. I don`t believe any other library has this to offer.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

Deleted the underscore in M_PI in "swisseph.bi" above. If somebody could look after the commented code, that would be great. I dont understand whats wrong there.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Post by lizard »

Made the conversion from swephexp.h to swisseph.bi with fbfrog again, because i was not sure if i deleted something.

Stll left unsure: "err", the "allocate" thing and the "TODOs".

For a normal horoscope it already works in this state, because only a few of all the functions needed. Further work would be only for others, which may want to do other things with this library.

Lets see if i can finish a 100% perfect conversion one day...
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Astro.com astronomical / astrological calculations

Post by dodicat »

Hi lizard.
Got it working on 64 bit fb, but not on 32 bit fb.
latitude and longitude are a bit confusing, is it not declination and hour angle (or right ascension) ?
The longitude bit seems degrees, the latitude bit seems a different unit.
I had to alter the .bi file a little to get it to run.
Post Reply