Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

3D with tikz

113 views
Skip to first unread message

Alain Matthes

unread,
Jul 23, 2009, 7:15:47 AM7/23/09
to
hi,

I make this try with an example of the cocumentation


\documentclass{minimal}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture} [scale=4]
\pgfsetfillcolor{lightgray}
\foreach \latitude in {-90,-75,...,30}
{
\foreach \longitude in {0,20,...,360}
{
\pgfpathmoveto{\pgfpointspherical{\longitude}{\latitude}{1}}
\pgfpathlineto{\pgfpointspherical{\longitude+20}{\latitude}{1}}
\pgfpathlineto{\pgfpointspherical{\longitude+20}{\latitude+15}{1}}
\pgfpathlineto{\pgfpointspherical{\longitude}{\latitude+15}{1}}
\pgfpathclose
}
\pgfusepath{fill,stroke}
}
\end{tikzpicture}
\end{document}

With tikz, I try

\documentclass{minimal}
\usepackage{tikz}

\begin{document}

\makeatletter
\define@key{sphericalkeys}{longitude}{\def\mylongitude{#1}}
\define@key{sphericalkeys}{latitude}{\def\mylatitude{#1}}
\define@key{sphericalkeys}{radius}{\def\myradius{#1}}

\tikzdeclarecoordinatesystem{spherical}%
{%
\setkeys{sphericalkeys}{#1}%
\pgfpointspherical{\mylongitude}{\mylatitude}{\myradius}
}
\begin{tikzpicture}[scale=4]

\foreach \numla in{-90,-75,...,90}
{\foreach \numlo in {0,10,...,360}
\path[draw,fill=gray!50,opacity=1]%
(spherical cs:longitude=\numlo,latitude=\numla,radius=1) to
(spherical cs:longitude=\numlo+10,latitude=\numla,radius=1) to
(spherical cs:longitude=\numlo+10,latitude=\numla+15,radius=1) to
(spherical cs:longitude=\numlo,latitude=\numla+15,radius=1);}
\end{tikzpicture}

\end{document}

But the library 3D in pgf 2.00 gives

% New coordinate systems:

\tikzdeclarecoordinatesystem{xyz spherical}
{%
\pgfset{/tikz/cs/.cd,angle=0,radius=0,latitude=0,longitude=0,#1}%
\pgfpointspherical{\tikz@cs@angle}{\tikz@cs@latitude}{\tikz@cs@radius}%
}
\pgfset{/tikz/cs/longitude/.store in=\tikz@cs@angle}
\pgfset{/tikz/cs/latitude/.store in=\tikz@cs@latitude}


But I have a problem with the next code

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,3d}
\begin{document}

\begin{tikzpicture}[scale=2]

\foreach \numla in{-90,-75,...,90}
{\foreach \numlo in {0,10,...,360}
\path[draw,fill=gray!50,opacity=1]%
(xyz spherical cs:longitude=\numlo,latitude=\numla,radius=1) to
(xyz spherical cs:longitude=\numlo+10,latitude=\numla,radius=1) to
(xyz spherical cs:longitude=\numlo+10,latitude=\numla+15,radius=1) to
(xyz spherical cs:longitude=\numlo,latitude=\numla+15,radius=1);}
\end{tikzpicture}
\end{document}

Error : macro undefined
why ???

Thanks

best Regards

Alain Matthes

Daniel Winkelmann

unread,
Jul 31, 2009, 12:58:35 PM7/31/09
to
Alain Matthes wrote:
>
>
> Error : macro undefined
> why ???
>

The line

\pgfset{/tikz/cs/radius/.store in=\tikz@cs@radius}

seems to be missing in the 3D library

I added it to your document

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,3d}

\makeatletter
\pgfset{/tikz/cs/radius/.store in=\tikz@cs@radius}
\makeatother


\begin{document}
\begin{tikzpicture}[scale=2]
\foreach \numla in{-90,-75,...,90}
{\foreach \numlo in {0,10,...,360}
\path[draw,fill=gray!50,opacity=1]%
(xyz spherical cs:longitude=\numlo,latitude=\numla,radius=1) to
(xyz spherical cs:longitude=\numlo+10,latitude=\numla,radius=1) to
(xyz spherical cs:longitude=\numlo+10,latitude=\numla+15,radius=1) to
(xyz spherical cs:longitude=\numlo,latitude=\numla+15,radius=1);}
\end{tikzpicture}
\end{document}

it worked

Daniel

Alain Matthes

unread,
Jul 31, 2009, 2:57:27 PM7/31/09
to
On 2009-07-31 18:58:35 +0200, "Daniel Winkelmann" <winke...@arcor.de> said:

> Alain Matthes wrote:
>>
>>
>> Error : macro undefined
>> why ???
>>
>
> The line
>
> \pgfset{/tikz/cs/radius/.store in=\tikz@cs@radius}
>
> seems to be missing in the 3D library
>
> I added it to your document

Thanks !

Best Regards

Alain Matthes

0 new messages