Graphics, Figures & TablesTExample "map projections" not working

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
weltio
Posts: 6
Joined: Tue Dec 25, 2012 3:52 am

TExample "map projections" not working

Post by weltio »

Hello

I can compile the following example
http://www.texample.net/tikz/examples/map-projections/
but it doesn't look like the given one.
I attached what I got and the log file. Is it related to the "Missing character: There is no . in font nullfont!" Messages?

I'm using the 2.02 release of TeXnicCenter with MikTex 2.9 64 Bit
Attachments
test.pdf
(49.54 KiB) Downloaded 405 times
test.log
(113.71 KiB) Downloaded 379 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

TExample "map projections" not working

Post by Stefan Kottwitz »

Hi weltio,

thank you very much for this observation!

Obviously .estyle (in \tikzset) does not work correctly any more with the current TikZ version. Possibly a bug. As I am the maintainer of the TeXample gallery, I corrected it in the file on the server, replaced it by .style.

Furthermore, I search for further occurrences, found some, and I replaced .estyle by .style in two further examples.

Thanks again,

Stefan
LaTeX.org admin
cyrlang
Posts: 5
Joined: Fri Jul 27, 2012 6:49 pm

TExample "map projections" not working

Post by cyrlang »

Hi,

I have problems with these codes for 3D graphics since TeXLive 2014. For me, changing .estyle for .style does not fix the bug : longitude planes are drawn, but
spherical-and-cartesian-grids.pdf
(45.64 KiB) Downloaded 259 times
lines and vectors are not drawn within the expected planes (see attachment). The bug persists with TeXLive 2016.
cyrlang
Posts: 5
Joined: Fri Jul 27, 2012 6:49 pm

TExample "map projections" not working

Post by cyrlang »

Hi again,
It's very strange : I obtained a correct drawing using .estyle in longitude macros and .style in latitude's one, and avoiding .prefix in the DrawLongitudeCircle command. Here is the changes I have made to the code of Marco Miani, with comments on the previous elements. Unfortunately, I made it by "trial and error" only, without a real understanding of the problem.

Code: Select all

% Author: Marco Miani
\documentclass[12pt]{article}
\usepackage{tikz}

%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>

\usetikzlibrary{positioning}
%% helper macros

% The 3D code is based on The drawing is based on Tomas M. Trzeciak's 
% `Stereographic and cylindrical map projections example`: 
% http://www.texample.net/tikz/examples/map-projections/
\newcommand\pgfmathsinandcos[3]{%
  \pgfmathsetmacro#1{sin(#3)}%
  \pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % azimuth
  \tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}
\newcommand\LatitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % latitude
  \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/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)},scale=#1}}
  %\tikzset{current plane/.prefix style={scale=#1}}
   % angle of "visibility"
  \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);
}
%this is fake: for drawing the grid
\newcommand\DrawLongitudeCirclered[2][1]{
  \LongitudePlane{\angEl}{#2}
  \tikzset{current plane/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)},scale=#1}}
  %\tikzset{current plane/.prefix style={scale=#1}}
   % angle of "visibility"
  \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  \draw[current plane,red,thick] (150:1) arc (150:180:1);
  %\draw[current plane,dashed] (-50:1) arc (-50:-35:1);
}%for drawing the grid
\newcommand\DLongredd[2][1]{
  \LongitudePlane{\angEl}{#2}
  \tikzset{current plane/.style={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)},scale=#1}}
  %\tikzset{current plane/.prefix style={scale=#1}}
   % angle of "visibility"
  \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}}
  %\tikzset{current plane/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)},scale=#1}}
  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  % angle of "visibility"
  \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}}
   % angle of "visibility"
  \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)}
  % angle of "visibility"
  \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);
}%Defining functions to draw limited latitude circles (for the red mesh)
\newcommand\DrawLatitudeCirclered[2][1]{
  \LatitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=#1}}
  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  % angle of "visibility"
  \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  %\draw[current plane,red,thick] (-\angVis-50:1) arc (-\angVis-50:-\angVis-20: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}%
}
\usepackage{amsmath}
\usetikzlibrary{arrows}
\pagestyle{empty}
\usepackage{pgfplots}
\usetikzlibrary{calc,fadings,decorations.pathreplacing}

\begin{document}
\begin{figure}[ht!]
	\begin{tikzpicture}[scale=1,every node/.style={minimum size=1cm}]
	%% some definitions
	
	\def\R{4} % 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
	
	%% working planes
	
	\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 (O) at (0,0);
	\coordinate[mark coordinate] (N) at (0,\H);
	\coordinate[mark coordinate] (S) at (0,-\H);
	\path[xzplane] (\R,0) coordinate (XE);
	
    %defining points outsided the area bounded by the sphere
	\path[qzplane] (\angBeta:\R+5.2376) coordinate (XEd);
	\path[pzplane] (\angBeta:\R) coordinate (P);%fino alla sfera
	\path[pzplane] (\angBeta:\R+5.2376) coordinate (Pd);%sfora di una quantità pari a 10 dopo la sfera
	\path[pzplane] (\angBeta:\R+5.2376) coordinate (Td);%sfora di una quantità pari a 10 dopo la sfera
	\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);%sfora di una quantità pari a 10 dopo la sfera
	
	\path[qzplane] (\R,0) coordinate (QE);
    \path[qzplane] (\R+4,0) coordinate (QEd);%sfora di una quantità 10 dalla sfera sul piano equat.


    \DrawLongitudeCircle[\R]{\angPhiOne} % pzplane
    \DrawLongitudeCircle[\R]{\angPhiTwo} % qzplane
    \DrawLatitudeCircle[\R]{\angBeta}
    \DrawLatitudeCircle[\R]{0} % equator
	%labelling north and south
	\node[above=8pt] at (N) {$\mathbf{N}$};
	\node[below=8pt] at (S) {$\mathbf{S}$};
	
	\draw[-,dashed, thick] (N) -- (S);
	\draw[->] (O) -- (P);
	\draw[dashed] (XE) -- (O) -- (PE);
	\draw[dashed] (O) -- (QE);
	%connecting Points outside the sphere
	\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 black thick flat grid
    \draw[-,ultra thick,black] (Pd) -- (PEd) node[below, left] {$P_1$};%verticale sinistro
    \draw[-,ultra thick,black] (PEd) -- (QEd)node[below, right] {$P_3$};%orizzontale inferiore
    \draw[-,ultra thick,black] (Pd)-- (XEd)node[above, right] {$P_2$};%orizzontale superiore	
    \draw[-,ultra thick,black] (XEd) -- (QEd);	
    		
	\draw[pzplane,->,thin] (0:0.5*\R) to[bend right=15]
	    node[midway,right] {$\lambda$} (\angBeta:0.5*\R);
	\path[pzplane] (0.5*\angBeta:\R) node[right] {$$};
	\path[qzplane] (0.5*\angBeta:\R) node[right] {$$};
	\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.6*\R) to[bend right=35]
	    node[midway,below] {$\phi_2$} (\angPhiTwo:0.6*\R);
			\path[xzplane] (0:\R) node[below] {$$};
	\path[xzplane] (\angBeta:\R) node[below left] {$$};
    \foreach \t in {0,2,...,30} {\DrawLatitudeCirclered[\R]{\t} }
	\foreach \t in {130,133,...,145} { \DrawLongitudeCirclered[\R]{\t} }
	
	%drawing grids on the sphere invoking DLongredd and DrawLongitudeCirclered
	
	\foreach \t in {130,145,...,145} { \DLongredd[\R+3]{\t} }
	\foreach \t in {130,133,...,145} { \DrawLongitudeCirclered[\R+3]{\t} }

	\foreach \t in {0,30,...,30} { \DLatred[\R+3]{\t} }
    \foreach \t in {0,2,...,30} { \DrawLatitudeCirclered[\R+3]{\t} }
	
    %labelling
    \draw[-latex,thick](4,-5.5)node[left]{$\mathsf{Grid(s)\ in\ Fig. \ (\ref{fig:Grid})}$}
    	         to[out=0,in=270] (5.8,-2.3);
    \draw[thick](3.6,-6)node[left]{$[\mathsf{Rectilinear}]$};
    	
\end{tikzpicture}
	\caption[Representation of spherical and regular computational grids used by SWAN]
    {Representation of spherical (red) and cartesian (black) co-ordinate systems. Latter 
    gives an example of unstructured grids. Both unstructured. Conversion from former 
    to latter involves a deformation factor which is acceptable within a given spatial limit. 
    For my case, only unstructured flat meshes are employed (\textit{Lisboa} Geodetic 
    datum: black grid on the right). Confront above represented points ($P_1,P_2,P_3$) with 
    Fig.(\ref{fig:Grid}). \\Mathematically frames change accordingly: see Eq.(\ref{eq:actbal2sph}).}
	\label{fig:frames}
\end{figure}
\end{document}
Post Reply