Files
mathematikfhtw/tikzgrafiken/tikz_test_01.tex
2020-10-24 13:47:37 +02:00

65 lines
2.0 KiB
TeX

\documentclass{article}
\usepackage{tikz,ifthen}
\usetikzlibrary{calc}
\pagestyle{empty}
\begin{document}
%% some definitions
\def\tikzplane#1#2#3#4#5{%
\pgfmathsetmacro\Xx{#2}% x coordiante of X axis unit vector
\pgfmathsetmacro\Xy{#3}% y coordiante of X axis unit vector
\pgfmathsetmacro\Yx{#4}% x coordiante of Y axis unit vector
\pgfmathsetmacro\Yy{#5}% y coordiante of Y axis unit vector
\tikzstyle{#1}=[cm={\Xx,\Xy,\Yx,\Yy,(0,0)}]% transformation matrix
}
\def\pgfmathsincos#1#2#3{%
\pgfmathsetmacro#1{sin(#3)}%
\pgfmathsetmacro#2{cos(#3)}%
}
% sphere radius
\def\R{4}
% elevation angle
\def\angEl{32}
% azimuth angle
\def\angAz{110}
% longitude of point P
\def\angPhi{-50}
% latitude of point P
\def\angBeta{-30}
\begin{tikzpicture}[>=latex] % option '>=latex' for nice arrows
\draw (0,0) circle (\R);
\foreach \t in {-80,-70,...,80} {
\pgfmathsincos\sint\cost{\t}
\pgfmathsincos\sinEl\cosEl{\angEl}
\pgfmathsetmacro\y{\R*\cosEl*\sint*1cm}
\tikzstyle{latitude circle}=[yshift=\y,yscale=\sinEl,scale=\cost]
\pgfmathsetmacro\sinLon{\sint/\cost*\sinEl/\cosEl}
\pgfmathtruncatemacro\testval{\sinLon}
\ifnum\testval=0
\pgfmathsetmacro\ang{asin(\sinLon)} % angle of "visibility"
\draw[latitude circle] (\ang:\R) arc (\ang:-\ang-180:\R);
\draw[latitude circle,dashed] (180-\ang:\R) arc (180-\ang:\ang:
\R);
\fi
\ifnum\testval>0
\draw[latitude circle] (0,0) circle(\R);
\fi
\ifnum\testval<0
\draw[latitude circle,dashed] (0,0) circle(\R);
\fi
}
\foreach \t in {-5,-35,...,-175} {
\pgfmathsincos\sint\cost{\t}
\pgfmathsincos\sinEl\cosEl{\angEl}
\tikzplane{xyplane}{\cost}{\sint*\sinEl}{0}{\cosEl}
\pgfmathsetmacro\ang{atan(\sint*\cosEl/\sinEl)} % angle of
"visibility"
\draw[xyplane,->] (180:1.7*\R) -- (0:1.7*\R);
\draw[xyplane] (\ang:\R) arc (\ang:\ang+180:\R);
\draw[xyplane,dashed] (\ang-180:\R) arc (\ang-180:\ang:\R);
}
\draw[->] (-90:1.3*\R) -- (90:1.3*\R);
\end{tikzpicture}
\end{document}