2011/05/21

Transformacion de coordenadas. Programa en Basic


cls
A=0:h=0:d=0:Ho=0
pri:
on error goto  pri


pi=4*atn(1)


r=2*pi/360   'grados a radianes
g=1/r        'radianes a grados


locate  8,10:print "(hs) Hora sideral"
locate  9,10:print "(o ) Latitud del observador"
locate 10,10:print "COORDENADAS HORIZONTALES"
locate 11,10:print "(A ) Acimut.........."
locate 12,10:print "(h ) Altura.........."
locate 13,10:print "COORDENADAS ECUATORIALES HORARIAS"
locate 14,10:print "(Ho) Angulo horario.."
locate 15,10:print "(d ) Declinacion....."
locate 16,10:print "COORDENADAS ECUATORIALES ABSOLUTAS"
locate 17,10:print "(Ar) Ascension recta."
locate 18,10:print "(d ) Declinacion....."
locate 19,10:print "COORDENADAS ECLIPTICAS"
locate 20,10:print "(lo) Longitud........"
locate 21,10:print "(la) Latitud........."


color 2,8
locate  8,40:'input hs$:call co(hs$,hs)
hs$="012 13 02"
locate  9,40:'input o$
'o$="041 12 06"
o$="-042 13 14"
call co(o$,o):print o$
locate 11,40:'input A$
'A$="310 42 02"
A$="023 17 22"
call co(A$,A):print A$
locate 12,40:'input h$
'h$="-071 42 06"
h$="-015 20 00"
call co(h$,h):print h$
color 4,7


if A=0 and h=0 then
  locate 14,25:input Ho$:call co(Ho$,Ho)
  locate 15,25:input  d$:call co( d$,d )
end if
if A=0 and h=0 and Ho=0 and d=0 then goto pri
if A<>0 and h<>0 then  gosub eh.ho


if A=0 and h=0 then
  m=atn(tan(d)/cos(Ho))
  A=atn(tan(Ho)*cos(m)/sin(o-m)): locate 11,25:call gra(A*g):print gr;mi;se
  h=pi/2-atn(tan(o-m)/cos(A))
  locate 12,35:call gra(h*g):print gr;mi;se
end if


end


'--------------------------------------------
sub cuadrante(y,z)
  shared pi
  if y>0 and z<pi then y=y
  if y>0 and z>pi then y=y+pi
  if y<0 and z<pi then y=y+pi
  if y<0 and z>pi then y=y+2*pi
end sub
'-------------


eh.ho:
  m=atn(tan((pi/2)-h)*cos(A))
  Ho=atn(tan(A)*sin(m)/cos(o-m))
  call cuadrante(Ho,A)
  locate 14,35:call gra(Ho*g):print gr;mi;se
  d=atn(tan(o-m)*cos(Ho))
  locate 15,35:call gra(d*g) :print gr;mi;se
return
'----------------


sub s
while inkey$="":wend
end sub
'----------------
sub co(h$,h)
  shared r
  sig=1
  if left$(h$,1)="-" then sig=-1:h$=right$(h$,9)
  h=val(left$(h$,3))+(val(mid$(h$,5,2)))/60+(val(right$(h$,2)))/3600
  h=sig*r*h
  if sig=-1 then h$="-"+h$
end sub
'-----------------
sub gra(g1)
  shared gr,mi,se
  sig=1:if g1<0 then sig=-1
  gr=int(abs(g1))
  m1=60*(abs(g1)-gr):mi=int(m1)
  s1=60*(m1-mi):se=cint(s1)
  gr=sig*gr

No hay comentarios: