LaTeX tikz 画地球示意图
发布时间
阅读量:
阅读量
画图代码如下:
%Author: Marco Miani
%LuaLaTeX / pdfLaTeX
\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
%\usepackage[active,tightpage]{preview}
%\PreviewEnvironment{tikzpicture}
%\setlength\PreviewBorder{5pt}
\usepackage{amsmath}
\usetikzlibrary{arrows}
\pagestyle{empty}
\usepackage{pgfplots}
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
\usetikzlibrary{positioning}
\begin{comment}
:Title: Spherical and cartesian grids
Representation of spherical (red) and cartesian (black) computational grids used
by SWAN_. Latter gives an example of unstructured grids. Conversion from former
to latter involves a deformation factor which is acceptable within a given spatial limit.
The drawing is based on Tomas M. Trzeciak's
`Stereographic and cylindrical map projections example`__.
.. __: http://www.texample.net/tikz/examples/map-projections/
.. _SWAN: http://www.texample.net/tikz/examples/swan-wave-model/
\end{comment}
\newcommand\pgfmathsinandcos[3]{
\pgfmathsetmacro#1{sin(#3)}
\pgfmathsetmacro#2{cos(#3)}
}
\newcommand\LongitudePlane[3][current plane]{
\pgfmathsinandcos\sinEl\cosEl{#2}
\pgfmathsinandcos\sint\cost{#3}
\tikzset{#1/.style={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}
\newcommand\LatitudePlane[3][current plane]{
\pgfmathsinandcos\sinEl\cosEl{#2}
\pgfmathsinandcos\sint\cost{#3}
\pgfmathsetmacro\yshift{\cosEl*\sint}
\tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}}
}
\newcommand\DrawLongitudeCircle[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane,thin,black] (\angVis:1) arc (\angVis:\angVis+180:1);
\draw[current plane,thin,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand\DrawLongitudeCirclered[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))}
\draw[current plane,red,thick] (150:1) arc (150:180:1);
}
\newcommand\DLongredd[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))}
\draw[current plane,black,dashed, ultra thick] (150:1) arc (150:180:1);
}
\newcommand\DLatred[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane,dashed,black,ultra thick] (-50:1) arc (-50:-35:1);
}
\newcommand\fillred[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))}
\draw[current plane,red,thin] (\angVis:1) arc (\angVis:\angVis+180:1);
}
\newcommand\DrawLatitudeCircle[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane,thin,black] (\angVis:1) arc (\angVis:-\angVis-180:1);
\draw[current plane,thin,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}
\newcommand\DrawLatitudeCirclered[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane,red,thick] (-50:1) arc (-50:-35:1);
}
\tikzset{
>=latex,
inner sep=0pt,
outer sep=2pt,
mark coordinate/.style={
inner sep=0pt,
outer sep=0pt,
minimum size=3pt,
fill=black,circle}
}
\begin{document}
\begin{figure}[ht!]
\begin{tikzpicture}[scale=1,every node/.style={minimum size=1cm}]
\def\R{5} % sphere radius
\def\angEl{25} % elevation angle
\def\angAz{-100} % azimuth angle
\def\angPhiOne{-50} % longitude of point P
\def\angPhiTwo{-35} % longitude of point Q
\def\angBeta{30} % latitude of point P and Q
\pgfmathsetmacro\H{\R*cos(\angEl)} % distance to north pole
\LongitudePlane[xzplane]{\angEl}{\angAz}
\LongitudePlane[pzplane]{\angEl}{\angPhiOne}
\LongitudePlane[qzplane]{\angEl}{\angPhiTwo}
\LatitudePlane[equator]{\angEl}{0}
\fill[ball color=white!10] (0,0) circle (\R); % 3D lighting effect
\coordinate[mark coordinate] (O) at (0,0);
\coordinate[mark coordinate] (N) at (0,\H);
\coordinate[mark coordinate] (S) at (0,-\H);
\path[xzplane] (\R,0) coordinate (XE);
\path[qzplane] (\angBeta:\R+5.2376) coordinate (XEd);
\path[pzplane] (\angBeta:\R) coordinate (P);
\path[pzplane] (\angBeta:\R+5.2376) coordinate (Pd);
\path[pzplane] (\angBeta:\R+5.2376) coordinate (Td);
\path[pzplane] (\R,0) coordinate (PE);
\path[pzplane] (\R+4,0) coordinate (PEd);
\path[qzplane] (\angBeta:\R) coordinate (Q);
\path[qzplane] (\angBeta:\R) coordinate (Qd);
\path[qzplane] (\R,0) coordinate (QE);
\path[qzplane] (\R+4,0) coordinate (QEd);
\DrawLongitudeCircle[\R]{\angPhiOne}
\DrawLongitudeCircle[\R]{\angPhiTwo}
\DrawLatitudeCircle[\R]{\angBeta}
\DrawLatitudeCircle[\R]{0}
\node[above=8pt] at (N) {$\mathbf{N}$};
\node[below=8pt] at (S) {$\mathbf{S}$};
\draw[-,dashed, thick] (N) -- (S);
\draw[->,ultra thick] (O) -- (P);
\draw[dashed,thick] (XE) -- (O) -- (PE);
\draw[dashed,ultra thick] (O) -- (QE);
\draw[-,dashed,black,very thick] (O) -- (Pd);
\draw[-,dashed,black,very thick] (O) -- (PEd);
\draw[-,dashed,black,very thick] (O) -- (QEd);
\draw[-,dashed,black,very thick] (O) -- (XEd);
\draw[dashed] (XE) -- (O) -- (PE);
\draw[-,ultra thick,black] (Pd) -- (PEd) node[below, left] {$P_1$};
\draw[-,ultra thick,black] (PEd) -- (QEd)node[below, right] {$P_3$};
\draw[-,ultra thick,black] (Pd)-- (XEd)node[above, right] {$P_2$};
\draw[-,ultra thick] (XEd) -- (QEd);
\draw[pzplane,->,thick] (0:0.4*\R) to [bend right=40]
node[midway,left] {$\beta$} (\angBeta:0.4*\R);
\path[pzplane] (0.5*\angBeta:\R) node[right] {$$};
\path[qzplane] (0.5*\angBeta:\R) node[right] {$$};
%draw \phi_1 and \phi_2
\draw[equator,->,thin] (\angAz:0.5*\R) to[bend right=30]
node[pos=0.4,above] {$\phi_1$} (\angPhiOne:0.5*\R);
\draw[equator,->,thin] (\angAz:0.7*\R) to[bend right=35]
node[midway,below] {$\phi_2$} (\angPhiTwo:0.7*\R);
\path[xzplane] (0:\R) node[below] {$$};
\path[xzplane] (\angBeta:\R) node[below left] {$$};
%draw Latitude and Longitude in the grid
\foreach \t in {0,5,...,30} { \DrawLatitudeCirclered[\R]{\t} }
\foreach \t in {130,135,...,145} { \DrawLongitudeCirclered[\R]{\t} }
%draw Latitude and Longitude in the grid
\foreach \t in {130,145,...,145} { \DLongredd[\R+3]{\t} } %outer Latitude black line
\foreach \t in {130,135,...,145} { \DrawLongitudeCirclered[\R+3]{\t} }
\foreach \t in {0,30,...,30} { \DLatred[\R+3]{\t} } %outer Longitude black line
\foreach \t in {0,5,...,30} { \DrawLatitudeCirclered[\R+3]{\t} }
%labelling
\draw[->,thick](4,-5.5)node[left]{$\mathsf{Grid(s)\ in\ Fig. 1}$}
to[out=0,in=270] (5.8,-2.8);
\draw[thick](3.6,-6)node[left]{$[\mathsf{Rectilinear}]$};
\end{tikzpicture}
\caption[Representation of spherical and regular computational grids used by SWAN]
{Write caption here.}
\label{fig:frames}
\end{figure}
\end{document}
编译结果如下:

声明:以上代码由 Marco Miani 所写,未能给出原文链接,在此表示歉意,同时感谢 Marco Miani 前辈!
全部评论 (0)
还没有任何评论哟~
