TikZ 中带有纬度和经度圆的椭圆

TikZ 中带有纬度和经度圆的椭圆

你们当中有人有聪明的编码方法吗

带虚线经度和纬度圆的椭圆

在 Tikz 中如何实现?目前,我自己的解决方案是绘制一个椭圆,然后明确指定每个虚线圆弧,这是一种彻底的平民化技术。

答案1

我非常喜欢 Altermundus 的解决方案,但如果你想要确切地你画了什么,我的做法如下:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node[draw,ellipse,minimum width=4cm,minimum height=2cm] (ell) {};
\foreach \ang in {-70,-60,...,70} {
  \pgfmathtruncatemacro{\rang}{180 - \ang}
  \draw[dashed,shorten >=1pt,shorten <=1pt] (ell.\ang) -- (ell.\rang);
}
\foreach \ang in {-65,-45,...,65} {
  \pgfmathsetmacro{\xrad}{2*sin(\ang)}
  \draw[dashed] (0,1) arc [x radius=\xrad,y radius=1,start angle=90,end angle=-90];
}
\end{tikzpicture}
\end{document}

结果:

椭圆

我认为,如果在设计中给予一点自由度,那么我会在自由度的线条上添加一条柔和的曲线。

答案2

下一个代码改编自globe.texTomasz M. Trzeciak 的代码

 \documentclass{scrartcl} 
\usepackage{tikz} 
\usetikzlibrary{calc} 
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\pagestyle{empty} 

\newcommand\pgfmathsinandcos[3]{% 
\pgfmathsetmacro#1{sin(#3)} 
\pgfmathsetmacro#2{cos(#3)}} 
\newcommand\LatitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2}
\pgfmathsinandcos\sint\cost{#3} 
}
\newcommand\LongitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2}
\pgfmathsinandcos\sint\cost{#3} 
\tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}}

\newcommand\DrawLatitudeCircle[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.estyle={cm={\cost,0,0,\cost*\sinEl,(0,\cosEl*\sint)}}}
\tikzset{current plane/.prefix style={xscale=\R,yscale=\RR}}

\pgfmathsetmacro\sinVis{tan(#2)*tan(\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,black!80] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}
\newcommand\DrawLongitudeCircle[2][1]{
  \LongitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={xscale=\R,yscale=\RR}}
% 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); 
}
\begin{document} 
\begin{tikzpicture}[scale=3]
\def\R{2.5}
\def\RR{3.5} 
\def\angEl{15}
\filldraw[ball color=gray!50] (0,0) circle[x radius=\R, y radius=\RR];
\foreach \t in {-80,-70,...,80} { \DrawLatitudeCircle[\R]{\t} }
\foreach \t in {-5,-35,...,-175} { \DrawLongitudeCircle[\R]{\t} }
\end{tikzpicture} 

\end{document}

在此处输入图片描述

答案3

这只是用我自己的代码和自己的包进行补充以获得类似的绘图:

\documentclass[a4paper]{scrartcl}
\usepackage[usenames,dvipsnames,svgnames]{xcolor}
\usepackage{tkz-euclide} 
\usetkzobj{all} 
\usepackage[frenchb]{babel} 
\definecolor{fondpaille}{cmyk}{0,0,0.1,0}   
\tkzSetUpColors[background=fondpaille,text=Maroon]  

\begin{document} 

  \begin{tikzpicture}[xscale=.6,yscale=.4]
    \tkzInit[xmin=-10,xmax=10,ymin=-10,ymax=10]
    \tkzDefPoint(0 , 0){O}
    \tkzDefPoint(9 , 0){A}
    \tkzDefPoint(-9, 0){C} 
    \tkzDefPoint(0 , 9){B}
    \tkzDefPoint(0 ,-9){D}
    \tkzClipCircle(O,A) 
    \foreach \pti in {1,2,...,8}{
    \tkzDefPoint(10*\pti:9){P\pti}
    \tkzDefPoint(90:\pti){MP\pti}
    \tkzDefPoint(0: \pti){NP\pti}
    \tkzDefLine[mediator](MP\pti,P\pti) 
    \tkzInterLL(B,D)(tkzFirstPointResult,tkzSecondPointResult) 
    \tkzDrawCircle[color=Maroon](tkzPointResult,P\pti)
    } 
    \foreach \pti in {-1,-2,...,-8}{
    \tkzDefPoint(10*\pti:9){P\pti}
    \tkzDefPoint(-90:-\pti){MP\pti}
    \tkzDefPoint(0: -\pti){NP\pti}
    \tkzDefLine[mediator](MP\pti,P\pti)  
    \tkzInterLL(B,D)(tkzFirstPointResult,tkzSecondPointResult)
    \tkzDrawCircle[color=Maroon](tkzPointResult,P\pti)
    } 
    \foreach \pti in {1,2,...,8}{
    \tkzDefLine[mediator](B,NP\pti)  
    \tkzInterLL(A,C)(tkzFirstPointResult,tkzSecondPointResult)  
    \tkzDrawCircle[color=Maroon](tkzPointResult,NP\pti)
    }
    \foreach \pti in {1,2,...,8}{
    \tkzDefPoint(0: -\pti){NP\pti}
    \tkzDefLine[mediator](B,NP\pti) 
    \tkzInterLL(A,C)(tkzFirstPointResult,tkzSecondPointResult)    
    \tkzDrawCircle[color=Maroon](tkzPointResult,NP\pti)
    }  
    \tkzDrawCircle[R,color=Maroon](O,9 cm)
    \tkzDrawSegments[color=Maroon](A,C B,D)  
  \end{tikzpicture}     

  \end{document} 

在此处输入图片描述

相关内容