Advertisement
Guest User

Untitled

a guest
Mar 5th, 2012
1,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 6.46 KB | None | 0 0
  1.  \documentclass[a4paper,10pt]{article}
  2.  
  3.  % Use UTF8 since the laptop is configured so and use ngerman for word breaking.
  4.  % If you encounter an encoding problem, remove the line with utf8.
  5.  \usepackage[utf8]{inputenc}
  6. \usepackage[ngerman]{babel}
  7. \usepackage[pdftex]{graphicx}
  8.  
  9.  % TikZ für schöne Grafiken und so.
  10.  \usepackage{tikz}
  11. \usetikzlibrary{positioning,calc,fadings,decorations.pathreplacing,arrows}
  12. \usepackage{pgfplots}
  13.  
  14. % \usepackage{hyperref}
  15.  \usepackage{colortbl}
  16. \usepackage{tabularx}
  17. \usepackage{color}
  18. \usepackage{amsfonts}
  19. \usepackage{amsmath}
  20. \usepackage{listings}
  21. \usepackage{multirow}
  22. \usepackage{fancyhdr}
  23. \usepackage{multicol}
  24. \usepackage{pdfpages}
  25. \usepackage[colorlinks=true,
  26.  linkcolor=black,
  27.  citecolor=black,
  28.  filecolor=black,
  29.  pagecolor=black,
  30.  urlcolor=black,
  31.  bookmarks=true,
  32.  bookmarksopen=true,
  33.  bookmarksopenlevel=3,
  34.  plainpages=false,
  35.  pdfpagelabels=true]{hyperref}
  36.  
  37. % Hack for german umlaute
  38. \lstset{
  39.  literate={ö}{{\"o}}1
  40.           {ä}{{\"a}}1
  41.           {ü}{{\"u}}1
  42. }
  43.  
  44.  % I set here a different sidemargin because the original margin looks not so
  45.  % good for normal documents. Additionally I have to enlarge the textwidth.
  46.  \setlength{\oddsidemargin}{0cm}
  47. \setlength{\evensidemargin}{0cm}
  48. \addtolength{\textwidth}{4cm}
  49. \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
  50.  
  51. \begin{document}
  52.  % Here I use the up-to-date font encoding T1 and the font familly Computer Modern
  53.  % Sans Serif (since I don't like the standard font) medium and normal (non-italic or so).
  54.  \usefont{T1}{cmss}{m}{n}
  55. \newcommand\pgfmathsinandcos[3]{%
  56.   \pgfmathsetmacro#1{sin(#3)}%
  57.   \pgfmathsetmacro#2{cos(#3)}%
  58. }
  59.  
  60. \newcommand\LongitudePlane[3][current plane]{%
  61.   \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  62.   \pgfmathsinandcos\sint\cost{#3} % azimuth
  63.   \tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
  64. }
  65.  
  66. \newcommand\LatitudePlane[3][current plane]{%
  67.   \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  68.   \pgfmathsinandcos\sint\cost{#3} % latitude
  69.   \pgfmathsetmacro\yshift{\cosEl*\sint}
  70.  \tikzset{#1/.estyle={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
  71. }
  72.  
  73. \newcommand\DrawLongitudeCircle[2][1]{
  74.  \LongitudePlane{\angEl}{#2}
  75.  \tikzset{current plane/.prefix style={scale=#1}}
  76.    % angle of "visibility"
  77.   \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  78.   \draw[current plane,thin,black] (\angVis:1) arc (\angVis:\angVis+180:1);
  79.   \draw[current plane,thin,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
  80. }%this is fake: for drawing the grid
  81.  
  82.  
  83. \newcommand\DrawLongitudeCirclered[2][1]{
  84.  \LongitudePlane{\angEl}{#2}
  85.  \tikzset{current plane/.prefix style={scale=#1}}
  86.    % angle of "visibility"
  87.   \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  88.   \draw[current plane,red,thick] (150:1) arc (150:180:1);
  89.   %\draw[current plane,dashed] (-50:1) arc (-50:-35:1);
  90. }%for drawing the grid
  91.  
  92.  
  93. \newcommand\DLongredd[2][1]{
  94.  \LongitudePlane{\angEl}{#2}
  95.  \tikzset{current plane/.prefix style={scale=#1}}
  96.    % angle of "visibility"
  97.   \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  98.   \draw[current plane,black,dashed, ultra thick] (150:1) arc (150:180:1);
  99. }
  100.  
  101.  
  102. \newcommand\DLatred[2][1]{
  103.  \LatitudePlane{\angEl}{#2}
  104.  \tikzset{current plane/.prefix style={scale=#1}}
  105.  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  106.   % angle of "visibility"
  107.   \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  108.  \draw[current plane,dashed,black,ultra thick] (-50:1) arc (-50:-35:1);
  109. }
  110.  
  111.  
  112. \newcommand\fillred[2][1]{
  113.  \LongitudePlane{\angEl}{#2}
  114.  \tikzset{current plane/.prefix style={scale=#1}}
  115.    % angle of "visibility"
  116.   \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  117.   \draw[current plane,red,thin] (\angVis:1) arc (\angVis:\angVis+180:1);
  118. }
  119.  
  120. \newcommand\DrawLatitudeCircle[2][1]{
  121.  \LatitudePlane{\angEl}{#2}
  122.  \tikzset{current plane/.prefix style={scale=#1}}
  123.  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  124.   % angle of "visibility"
  125.   \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  126.  \draw[current plane,thin,black] (\angVis:1) arc (\angVis:-\angVis-180:1);
  127.  \draw[current plane,thin,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1);
  128. }%Defining functions to draw limited latitude circles (for the red mesh)
  129.  
  130.  
  131. \newcommand\DrawLatitudeCirclered[2][1]{
  132.  \LatitudePlane{\angEl}{#2}
  133.  \tikzset{current plane/.prefix style={scale=#1}}
  134.  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  135.   % angle of "visibility"
  136.   \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  137.   %\draw[current plane,red,thick] (-\angVis-50:1) arc (-\angVis-50:-\angVis-20:1);
  138. \draw[current plane,red,thick] (-50:1) arc (-50:-35:1);
  139. }
  140.  
  141.  
  142. \tikzset{
  143.  >=latex,
  144.  inner sep=0pt,
  145.  outer sep=2pt,
  146.  mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt, fill=black,circle}
  147. }
  148.  
  149. \begin{tikzpicture}[scale=1,every node/.style={minimum size=1cm}]
  150.     %% some definitions
  151.    
  152.     \def\R{4} % sphere radius
  153.    
  154.     \def\angEl{25} % elevation angle
  155.     \def\angAz{-100} % azimuth angle
  156.     \def\angPhiOne{-110} % longitude of point P
  157.     \def\angPhiTwo{-45} % longitude of point Q
  158.     \def\angBeta{30} % latitude of point P and Q
  159.    
  160.     %% working planes
  161.    
  162.     \pgfmathsetmacro\H{\R*cos(\angEl)} % distance to north pole
  163.     \LongitudePlane[xzplane]{\angEl}{\angAz}
  164.     \LongitudePlane[pzplane]{\angEl}{\angPhiOne}
  165.     \LongitudePlane[qzplane]{\angEl}{\angPhiTwo}
  166.        \LongitudePlane[nzplane]{\angEl}{-86}
  167.     \LatitudePlane[equator]{\angEl}{0}
  168.     \fill[ball color=white!10] (0,0) circle (\R); % 3D lighting effect
  169.     \coordinate (O) at (0,0);
  170.     \coordinate[mark coordinate] (N) at (0,\H);
  171.     \coordinate[mark coordinate] (S) at (0,-\H);
  172.    
  173.     \DrawLongitudeCircle[\R]{\angPhiOne} % pzplane
  174.     \DrawLongitudeCircle[\R]{\angPhiTwo} % qzplane
  175.     \DrawLatitudeCircle[\R]{\angBeta}
  176.    \DrawLatitudeCircle[\R]{0} % equator
  177.     %labelling north and south
  178.     \node[above=8pt] at (N) {$\mathbf{N}$};
  179.     \node[below=8pt] at (S) {$\mathbf{S}$};
  180.         \draw[-,dashed, thick] (N) -- (S);
  181.  
  182.     %setup coordinates P and Q
  183.     \path[pzplane] (0:\R) coordinate (P);
  184.     \draw[->] (O) -- node[above=4pt] {$\overrightarrow{P}$} (P);
  185.    \path[qzplane] (\angBeta:\R) coordinate (Q);
  186.    \draw[->] (O) -- node[above=2pt] {$\overrightarrow{Q}$} (Q);
  187.    \path[nzplane] (153:\R) coordinate (N);
  188.    \draw[->,color=red] (O) -- node[right=2pt] {$\overrightarrow{N}$} (N);
  189.     \draw (P) arc (-110:-45:\R) (Q);   
  190. \end{tikzpicture}
  191.  
  192. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement