%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                           %%
%% This is file `pst-eqhz.tex',                                              %%
%%                                                                           %%
%% IMPORTANT NOTICE:                                                         %%
%%                                                                           %%
%% Package `pst-eqhz'                                                        %%
%%                                                                           %%
%% Manuel Luque             
%% Herbert Voß <hvoss@tug.org>                                                 %%
%%                                                                           %%
%% May 19, 2026                                                             %%
%%                                                                           %%
%% This program can be redistributed and/or modified under the terms         %%
%% of the LaTeX Project Public License Distributed from CTAN archives        %%
%% in directory macros/latex/base/lppl.txt.                                  %%
%%                                                                           %%
%% DESCRIPTION:                                                              %%
%%   `pst-eqhz' is a PSTricks tools                                          %%
%%    to represent the equatorial system surimposed on the horizontal system %%
%%    based on an idea of the professor Kim                                  %%
%%    https://web.njit.edu/~hmkim/phys322/Phy_322_Basics_2019Spring.pdf      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\csname PSTEqhz\endcsname
\let\PSTEqhz\endinput

% Require PSTricks
\ifx\PSTricksLoaded\endinput      \else  \input pstricks.tex\fi
\ifx\PSTSOLIDESIIIDLoaded\endinput\else  \input pst-solides3d.tex\fi
\ifx\PSTmathLoaded\endinput       \else  \input pst-math.tex\fi
\ifx\PSTfunLoaded\endinput        \else  \input pst-fun.tex\fi
\ifx\PSTXKeyLoaded\endinput       \else  \input pst-xkey\fi
\RequirePackage{fp}
\FPmessagesfalse
%
\def\fileversion{0.01}
\let\EQHZfileversion\fileversion
\def\filedate{2026/05/19}
\let\EQHZfiledate\filedate
\message{`pst-eqhz' v\fileversion, \filedate\space (ML,HV)}

\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
%\pstheader{meridianparallel.pro}
\pstheader{pst-eqhz.pro}
\addtosolideslistobject{parallel,meridian}

\pst@addfams{pst-eqhz}

\define@key[psset]{pst-eqhz}{dAngle}{\def\dA{#1 }}
\psset{dAngle=15}% angle entre deux méridiens ou deux parallèles
\define@key[psset]{pst-eqhz}{colatitude}{\def\colatitude{#1 }}
\psset{colatitude=45}% colatitude du lieu d'observation
%% choisir un multiple de dA
\define@key[psset]{pst-eqhz}{RA}{\def\RA{#1 }}   % ascension droite de l'étoile
\define@key[psset]{pst-eqhz}{Dec}{\def\Dec{#1 }} % déclinaison de l'étoile
\psset{RA=45,Dec=45}% choisir des multiples de dA
\define@boolkey[psset]{pst-eqhz}[Pst@]{names}[true]{}
\psset{names=true} % les noms : équateur céleste etc.
\define@boolkey[psset]{pst-eqhz}[Pst@]{image}[true]{}
\psset{image=true} % draw triangular in the center
\psset{solidmemory,r=5}%

\def\psEquatorialHorizontal{\pst@object{psEquatorialHorizontal}}
\def\psEquatorialHorizontal@i{%
  \addbefore@par{solidmemory,r=5}%
  \begin@SpecialObj
  \psSolid[object=plan,definition=normalpoint,
         args={0 0 0 [0 0 1]},RotX=0,
         action=none,
         name=eqhz-base]%
  \psProjection[object=cercle,args=0 0 5,range=0 360,plan=eqhz-base,linewidth=0.05,resolution=360,fillstyle=solid,fillcolor=orange!50!green!20]
  \psProjection[object=line,args=-5 0 5 0,plan=eqhz-base,linecolor=red]%
  \psProjection[object=line,args=0 -5 0 5,plan=eqhz-base,linecolor=red]%
  \psProjection[object=texte,text=E,fontsize=20,linecolor=red,plan=eqhz-base,phi=90](6,0)%
  \psProjection[object=texte,text=O,fontsize=20,linecolor=red,plan=eqhz-base,phi=90](-6,0)%
  \psProjection[object=texte,text=N,fontsize=20,linecolor=red,plan=eqhz-base,phi=90](0,5.5)%
  \psProjection[object=texte,text=S,fontsize=20,linecolor=red,plan=eqhz-base,phi=90](0,-5.5)%
  \composeSolid
  \ifPst@image
    \psImage[filename=triangular.eps,
      normal=1 1 0,
      origine=0 0 0.2,
      phi=0,
      visibility,
      unitPicture=150](-2,-1)%(-1,-0.4)
  \fi
  \pstVerb{
	/CoLatitud \colatitude\space def
	/na 0 def /nb CoLatitud sin neg def /nc CoLatitud cos def
	/sinT {nc nb div phi0 sin mul phi0 cos div neg} def
	/tanF {nb nc div theta0 sin mul neg} def
	/theta0 {sinT arcsin} def
	/phi0 {tanF arctan } def
  }%
%  \FPeval{\nMeridiens}{clip(round(180/\dA,0))}%
  \edef\nMeridiens{\pscalc{round(180/\dA)}}
%  \typeout{------>\nMeridiens}%
  \bgroup
  \psset{linewidth=1pt,RotX=-\colatitude}%
  \multido{\iA=0+\dA}{\nMeridiens}{%
     \pstVerb{/theta0 \iA\space def}%
     \composeSolid
     \psSolid[object=meridian, args=phi0 180 phi0 add, theta=theta0, linecolor=blue]%
     \ifnum\iA>0 \composeSolid\fi
   }
    % parallèles de -colatitude du lieu à +colatitude du lieu
    \pstVerb{/theta0 {sinT arcsin} def}%
    \FPeval{\nvaleurs}{clip(round(2*\colatitude/\dA,0))}%
    \multido{\r=-\colatitude+\dA}{\nvaleurs}{%
	  \pstVerb{/phi0 \r\space def sinT abs 1 ge {/phi0 \r\space \dA\space add def} if}%
	  \psSolid[object=parallel,args=theta0 theta0 neg 180 sub ,phi=phi0,linecolor=blue]
	  \composeSolid
	}%
% parallèles de +colatitude du lieu à 90°
% avec le même pas que les précédentes
    \FPeval{\valeur}{clip(round((90-\colatitude)/\dA,0))}%
    \multido{\R=\colatitude+\dA}{\valeur}{%
	  \pstVerb{/phi0 \R\space def}%
	  \psSolid[object=parallel,args=0 360 ,phi=phi0,linecolor=blue]
	  \composeSolid}
  \egroup
% méridien d'origine
  \pstVerb{/theta0 -90 def /phi0 {tanF arctan } def}
  \psSolid[object=meridian,args=phi0 phi0 180 add ,theta=theta0,linecolor=red,RotX=-\colatitude]%
  \composeSolid%
% équateur céleste
  \pstVerb{/phi0 0 def /theta0 {sinT arcsin} def}%
  \psSolid[object=parallel,args=theta0 theta0 neg 180 sub ,phi=phi0,linecolor=red,RotX=-\colatitude]%
  \psSolid[object=vecteur,linecolor=orange,RotX=0,args=0 0 2.5](0,0,5)%
  \psLineIIID[linestyle=dashed,linecolor=orange](0,0,0)(0,0,5)
  \psPoint(0,0,8){Z}%
  \psarc(0,0){5}{0}{180}
% vecteur vers le nord : axe des pôles
  \psTransformPoint[RotX=-\colatitude](0 0 5)(0,0,0){Nord}
  \psline[linestyle=dashed,linecolor=red](Nord)
  \psTransformPoint[RotX=-\colatitude](0 0 7.5)(0,0,0){Nord2}
  \psSolid[object=vecteur,linecolor=red,RotX=-\colatitude,
         args=2.5 0 90 rtp2xyz,transform={0 0 5 CoLatitud neg 0 0 rotateOpoint3d translatepoint3d}]%
  \psLineIIID[linestyle=dashed,linecolor=orange](0,0,0)(0,0,5)
  \composeSolid
  \psSolid[object=plan,definition=normalpoint,args={0 0 6.5 CoLatitud neg 0 0 rotateOpoint3d [ 0 0 1 CoLatitud neg 0 0 rotateOpoint3d]},
         action=none,RotX=0,
         name=sensRotation]
  \psProjection[object=cercle,linewidth=0.05,resolution=360,range=-120 120,
              plan=sensRotation,
              args=0 0 0.5]%
  % sens de rotation de la voûte céleste
  \psProjection[object=vecteur,linewidth=0.05,plan=sensRotation,
        args=-0.5  -0.342 sub 0.5 mul -0.866 -0.94 sub 0.5 mul ](-0.25,-0.433)%
% méridien d'origine
  \psPoint(0,5 20 cos mul, 5 20 sin mul){M1}
  \psPoint(0,6 20 cos mul, 7 20 sin mul){M2}
% équateur céleste
  \psTransformPoint[RotX=-\colatitude](5 -10 cos mul 5 -10 sin mul 0)(0,0,0){E1}
  \psTransformPoint[RotX=-\colatitude](7 -10 cos mul 8 -10 sin mul 0)(0,0,0){E2}
% ascension droite RA et déclinaison Dec d'une étoile
  \pstVerb{/phi0 0 def /Dec \Dec def /RA \RA def}%
  \psSolid[object=parallel,args=-90 RA -90 add ,phi=phi0,linecolor=orange,linewidth=0.1,RotX=-\colatitude]
  \psSolid[object=meridian,args=0 Dec ,theta=RA -90 add,linecolor=cyan,linewidth=0.1,RotX=-\colatitude]\composeSolid
  \psSolid[object=sphere,r=0.1,grid,fillcolor=yellow,lightsrc=viewpoint](5 RA -90 add Dec rtp2xyz CoLatitud neg 0 0 rotateOpoint3d /zp exch def /yp exch def,yp, zp)
  \psTransformPoint(5.2 RA -90 add Dec rtp2xyz CoLatitud neg 0 0 rotateOpoint3d)(0,0,0){star1}
  \psTransformPoint(9 Dec 90 sub Dec rtp2xyz CoLatitud neg 0 0 rotateOpoint3d)(0,0,0){star2}
  \psTransformPoint(5 RA 90 sub Dec 2 div rtp2xyz CoLatitud neg 0 0 rotateOpoint3d)(0,0,0){Dec1}
  \psTransformPoint(8.25 RA 90 sub Dec 2 div rtp2xyz CoLatitud neg 0 0 rotateOpoint3d)(0,0,0){Dec2}
  \psTransformPoint(5 RA 90 add -2 div 0 rtp2xyz CoLatitud neg 0 0 rotateOpoint3d)(0,0,0){RA1}
  \psTransformPoint(7.5 RA 90 add -2 div 0 rtp2xyz CoLatitud neg 0 0 rotateOpoint3d)(0,0,0){RA2}
  \psTransformPoint(5 15 0 rtp2xyz 0 neg 0 0 rotateOpoint3d)(0,0,0){H}
  \ifPst@names
  	\psline[arrowinset=0.1,arrowsize=0.15]{->}(M2)(M1)
  	\uput[r](M2){prime meridian (RA=0)}
  	\psline[arrowinset=0.1,arrowsize=0.15]{->}(E2)(E1)
  	\uput[l](E2){celestial equator}
  	\psline[arrowinset=0.1,arrowsize=0.15]{->}(star2)(star1)
  	\uput[u](star2){star}
  	\psline[arrowinset=0.1,arrowsize=0.15]{->}(Dec2)(Dec1)
  	\uput[u](Dec2){declinatson}
  	\psline[arrowinset=0.1,arrowsize=0.15]{->}(RA2)(RA1)
  	\uput[u](RA2){right ascension}
  	\uput[d](H){horizon}
  	\rput(Z){Zenith}
  	\uput[ur](Nord2){towards Polaris}%
  \fi
  \end@SpecialObj
  \ignorespaces
}%
\catcode`\@=\PstAtCode\relax

\endinput 