Something I been working over a few years, has some clever maths bits in it worked out by members on this forum. uses standard draw command.
Rem Project: astroclock6
Rem Created: Tuesday, December 22, 2009
Rem ***** Main Source File *****
Rem Project: astroclock5
Rem Created: Monday, December 21, 2009
Rem ***** Main Source File *****
Rem Project: astroclock2
Rem Created: 15/10/2008 20:31:47
Rem ***** Main Source File *****
sync on
sync rate 60
X# = screen width()/2
Y# = screen height()/2
rem size of circles
bigradius# = 200.0
smallradius# = 120.0
linelength# = 120.0
hourlinelength =300
i=0
hourxstart#=x#+hourlinelength
houryend#=y#
rem find date and time
date$=get date$()
print date$
month =val(left$(date$,2))
day = val(mid$(date$,4)+mid$(date$,5))
year = val("20"+right$(date$,2))
N1 = floor( (275 * month) / 9)
N2 = floor((month + 9) / 12)
N3 = (1.0 + floor((year - 4.0 * floor(year / 4.0) + 2.0) / 3.0))
N = N1 - (N2 * N3) + day - 30
moon2=moon_phase2(year,month,day)
print moon2
theta#=(n/n3)
Do
CLS
rem chop up the time
time$ = get time$()
hr# = val(left$(time$,2))*60.0*60.0
min# = val(mid$(time$,4)+mid$(time$,5))*60.0
sec# = val(right$(time$,2))
`hr# = 2.0*60.0*60.0
`min# = 0.0*60.0
`sec# = 0.0
rem print the time
text 0,0,time$
text 0,12,str$(Angle#)
text 0,24,str$(hr#+min#+sec#)
text 0,36,str$(moon2)
rem outter circle.
ink RGB(255,255,255),0
circle X#,Y#,bigradius#
for i = 0 to 360 step 15
mihourxstart#=X#+Cos(i)*210
mihouryend#=Y#+Sin(i)*210
mohourxstart#=X#+Cos(i)*220
mohouryend#=Y#+Sin(i)*220
line mihourxstart#,mihouryend#,mohourxstart#,mohouryend#
next i
rem hour hand calulation position.
`inc seconds#,120
Angle#=((hr#+min#+sec#)/240)+90
`Angle#=(seconds#/360)+205
` ; calc the end of the second hands end
hourxend#=X#+Cos(Angle#)*210
houryend#=Y#+Sin(Angle#)*210
rem draws hour hand.
ink RGB(255,100,255),0
line x#,y#,hourxend#,houryend#
rem center point of inner circle.
X2# = X#+(bigradius#-smallradius#)*SIN(theta#)
Y2# = Y#+(bigradius#-smallradius#)*COS(theta#)
rem connetion point on inner circle.
ink rgb(35,245,234),0
circle X#+(bigradius#-smallradius#)*SIN(theta#),Y#+(bigradius#-smallradius#)*COS(theta#),5
hourHandDirX# = Cos(Angle#)
hourHandDirY# = Sin(Angle#)
rayFromX# = X2# - x#
rayFromY# = Y2# - y#
b# = rayFromX# * hourHandDirX# + rayFromY# * hourHandDirY#
c# = rayFromX# * rayFromX# + rayFromY# * rayFromY# - smallradius# * smallradius#
d# = b# * b# - c#
e# = -b# - sqrt(d#)
hitX# = x# - e# * hourHandDirX#
hitY# = y# - e# * hourHandDirY#
rem sun circle
ink RGB(255,255,0),0
line X2#,Y2#,hitX#, hitY#
circle hitX#, hitY#, 10
rem offset inner circle.
ink rgb(255,255,255),0
circle X2#,Y2#,smallradius#
circle x#,y#,bigradius#-smallradius#
rem cord line on inner circle
ink rgb(255,0,0),0
xl#=sin(theta#+90)*90.0
yl#=cos(theta#+90)*90.0
`text 0,36,"theta# = "+str$(theta#-66)+ " angle# = "+str$(angle#+90)+" "+str$(x#-xl2#-x#)+" "+str$(atanfull(x#-bigradius#,y#-smallradius#))
`text 0,73,"atan(theta# = "+str$(theta#-66)+ "/ angle# "+str$(angle#-270)+")= "+str$(atan(theta#-66/angle#-270))
ta#=atan(theta#-66/angle#-270)
xl2#=sin(theta#+90)*130.0
yl2#=cos(theta#+90)*130.0
line x#,y#,x#-xl2#,y#-yl2#
line x#,y#,x#+xl#,y#+yl#
circle x#-xl2#,y#-yl2#,5
rem line to center form cord
ink rgb(255,0,0),0
line x2#,y2#,x#+xCircleCoord(ta#, smallradius#),y#+yCircleCoord(ta#,smallraduis#)
rem moon
moonoffset=170
ink RGB(255,0,128),0
if moon2<>0
xp#=x2#+cos((360/moon2)-moonoffset)*smallradius#
yp#=y2#+sin((360/moon2)-moonoffset)*smallradius#
else
xp#=x2#+cos((moon2)-moonoffset)*smallradius#
yp#=y2#+sin((moon2)-moonoffset)*smallradius#
endif
line X2#,Y2#, xp#,yp#
circle xp#,yp#,4
`theta# = theta# - n
if hr#>oldhr#
oldhr#=hr#
if moon2<>0
moon# =wrapvalue((360/moon2)-moonoffset)
else
moon# =wrapvalue((moon2)-moonoffset)
endif
ENDIF
text 0,48,"Moon angle ="+str$(moon#)
sync
Loop
function xCircleCoord(angle as float, radius as float)
set cursor 0,100
retval as float : retval = radius * cos(angle)
print "x circle =",retval
endfunction retval
function yCircleCoord(angle as float, radius as float)
retval as float : retval = radius * sin(angle)
print "y circle =", retval
endfunction retval
function moon_phase2(y as integer, m as integer, d as integer)
` calculates the moon phase (0-7), accurate to 1 segment.
` 0 = > new moon.
` 4 => full moon.
jd1 as float
b1 as float
if m < 3
dec y
m = m + 12
endif
c1 = 365.25*y
e1 = 30.6*m
jd1 = c1+e1+d-694039.09 :`; /* jd is total days elapsed */
jd1 =jd1 / 29.53 :`; /* divide by the moon cycle (29.53 days) */
b1 = int(jd1) :`; /* int(jd) -> b, take integer part of jd */
jd1 = jd1-b1 :`; /* subtract integer part to leave fractional part of original jd */
b1 = jd1*8 + 0.5 :`; /* scale fraction from 0-8 and round by adding 0.5 */
b1 = b1 && 7 :`; /* 0 and 8 are the same so turn 8 into 0 */
endfunction b1
Dark Physics makes any hot drink go cold.