4

i took this one http://www.texample.net/tikz/examples/map-projections and rebuild or changed it for my use. This is a crosspost to: http://latex-community.org/forum/viewtopic.php?f=45&t=25078&p=85229#p85229

I got the problem that the code I modified is kinda old so... well I show you: I want this:

what i want

which works in writeLatex, the problem is it uses estyle which leads to removed latitude and longitude circles using texniccenter and miktex:

what i don't want

Replacing estyle by style, makes the lines appear again, but confused all the nodes:

what i get

As far as I now this is a problem of the old code I am using, I would really appreciate some suggestions or somebody who knows the changes of tikz from i guess 1.5 to 3.0+

Maybe somebody knows simply how to place my points right again, I guess the rest would drop in then.

Thanks and kind regards sty

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\pagestyle{empty}

%% helper macros
\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/.style={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][4]{
  \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] (\angVis:1) arc (\angVis:\angVis+180:1);
  \draw[current plane,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand\DrawLatitudeCircle[2][5]{
  \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] (\angVis:1) arc (\angVis:-\angVis-180:1);
  \draw[current plane,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}

%% document-wide tikz options and styles
\tikzset{%
  >=latex, % option for nice arrows
  inner sep=0pt,%
  outer sep=2pt,%
  mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt,fill=black,circle}%
}

\begin{document}

\begin{tikzpicture} % CENT

%% some definitions
\def\R{4} % sphere radius
\def\angEl{35} % elevation angle
\def\angAz{-105} % azimuth angle
\def\angPhi{-40} % longitude of point P
\def\angBeta{25} % latitude of point P

%% working planes
\pgfmathsetmacro\H{\R*cos(\angEl)} % distance to north pole
\tikzset{xyplane/.estyle={cm={cos(\angAz),sin(\angAz)*sin(\angEl),-sin(\angAz),cos(\angAz)*sin(\angEl),(0,-\H)}}}
\LongitudePlane[xzplane]{\angEl}{\angAz}
\LongitudePlane[pzplane]{\angEl}{\angPhi}
\LongitudePlane[yzplane]{\angEl}{\angAz+90}
\LatitudePlane[equator]{\angEl}{0}

%% draw xyplane and sphere
\fill[ball color=white] (0,0) circle (\R); % 3D lighting effect
\draw (0,0) circle (\R);

\coordinate (O) at (0,0);
\coordinate[mark coordinate] (N) at (0,\H);
\coordinate[mark coordinate] (S) at (0,-\H);
%\path[pzplane] (\angBeta:\R) coordinate[mark coordinate] (P);
\path[pzplane] (\angBeta:\R) coordinate[mark coordinate] (P1);
\path[pzplane] (-\angBeta:\R) coordinate[mark coordinate] (P2);
\path[pzplane] (\angBeta:2.2*\R) coordinate (P11);
\path[pzplane] (-\angBeta:1.8*\R) coordinate (P22);
\path[pzplane] (\angBeta:0.5*\R) coordinate (P15);
\path[pzplane] (-\angBeta:0.5*\R) coordinate (P25);

%% draw meridians and latitude circles
\DrawLatitudeCircle[\R]{0} % equator
\DrawLongitudeCircle[\R]{\angAz} % xzplane
\DrawLongitudeCircle[\R]{\angAz+90} % yzplane
\DrawLongitudeCircle[\R]{\angPhi} % pzplane

%% draw xyz coordinate system

\draw[xzplane,->] (0,0) -- (1.9*\R,0) node[below] {$x$};
\draw[yzplane,->] (0,0) -- (1.4*\R,0) node[below] {$y$};
\draw[->]                 (0,0) -- (0,1.3*\R) node[above] {$z$};
\draw[pzplane,->] (0,0) -- (1.5*\R,0) node[below] {$x_{2}$};

%% draw lines and put labels
\draw[dashed] (S) -- (N) +(0.3ex,0.6ex) node[above left] {$\mathbf{N}$};
\path (S) +(0.4ex,-0.4ex) node[below] {$\mathbf{S}$};
\draw[dashed] (P11) -- (P1) -- (O) -- (P2) -- (P22);
\draw[->,thin] (P22) to[bend right=25] node[pos=0.5,right] {$\beta$} (P11);
\draw[equator,->,thin] (\angAz:0.5*\R) to[bend right=30] node[pos=0.44,below]   {$\theta$} (\angPhi:0.5*\R);

\end{tikzpicture}
\end{document} 

This is a bloody workaround, by setting the points manually.

%######################################################################
% alternative to good style method
\coordinate[mark coordinate] (P1) at (2.775,0.05); %good
\coordinate (P11) at (6.1,0.115); %good
\coordinate (pt15) at (1.39,0.02); %good
\coordinate[mark coordinate] (P2) at (2.78,-2.725); %good
\coordinate (P22) at (5,-4.9); %good
\coordinate (P25) at (1.39,-1.36); %good
%######################################################################

%######################################################################
% more alternative or workaround
%\coordinate[mark coordinate,red] (x1) at (-1.95,-4.2);
\coordinate (x1) at (-1.95,-4.2);
\draw[->] (O)--(x1) node[below] {$x_{CIO}$};
\coordinate (y1) at (5.45,-0.81);
\draw[->] (O) -- (y1) node[below] {$y_{CIO}$};
\coordinate (x2) at (4.6,-2.2);
\draw[->] (O) -- (x2) node[below] {$x_{TIO}$};
\coordinate (z1) at (0,5);
\draw[->]           (O) -- (z1) node[above] {$z_{CIP}$};
%######################################################################
6
  • See the comments on this one tex.stackexchange.com/questions/181252/…
    – percusse
    Aug 18, 2014 at 17:02
  • It does not solve my problem, have you read my complete question, if so can you specify which comment.
    – startrucky
    Aug 18, 2014 at 17:06
  • I mean switching to /.style is not a fix right away. It needs a more general fix and there is a ticket for this in the PGF bugtracker. Did you read the comments?
    – percusse
    Aug 18, 2014 at 17:09
  • Ok so the ticket #306 is explaining the problem right? which i don't understand, but that means i have to wait for tikz to update?
    – startrucky
    Aug 18, 2014 at 17:13
  • Please see also the crosspost on LaTeX community: latex-community.org/forum/viewtopic.php?f=45&t=25078
    – cgnieder
    Aug 18, 2014 at 18:41

1 Answer 1

2

So after some time I wanted to use this again and I actually found a pretty interesting solution. The following:

\path[pzplane] (\angBeta:\R) coordinate[mark coordinate] (P1);

needs to be changed to:

\path[pzplane] (\angBeta:\R/1) coordinate[mark coordinate] (P1);

see the difference ;-P

Well took me a while to figure that out but it seems to work, deviding \r by 1 somehow is a workaround.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .