![围绕球体的3D轨道、圆弧点或轨道坐标定位](https://linux22.com/image/308115/%E5%9B%B4%E7%BB%95%E7%90%83%E4%BD%93%E7%9A%843D%E8%BD%A8%E9%81%93%E3%80%81%E5%9C%86%E5%BC%A7%E7%82%B9%E6%88%96%E8%BD%A8%E9%81%93%E5%9D%90%E6%A0%87%E5%AE%9A%E4%BD%8D.png)
我又有关于 3D tikz 问题的问题了。已添加交叉帖子:http://www.latex-community.org/forum/viewtopic.php?f=45&t=26046 添加了德语交叉帖子:http://texwelt.de/wissen/fragen/12291/3d-orbits-um-sphare-mit-koordinaten-oder-punkten-auf-umlaufbahn
这是 overleaf(writelatex)部分的链接,我不知道是否有人可以打开它,但它在这里。 https://www.overleaf.com/2433347sbhpck#/6330259/
现在来看看实际问题:
问题在于使用路径命令引用以前定义的平面。蓝点和黑点的坐标在蓝点和绿点轨道上起作用。
橙点不在它们应该在的平面上,它们应该在红线上,也就是 O 和 o 所在的位置,所以请有人能帮我找出我遗漏了什么。
\documentclass{文章} \usepackage{tikz,tikz-3dplot} \usetikzlibrary{calc,fadings,decorations.pathreplacing}
%% 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{\OrbitPlane}[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{\DrawLongitudeCircle}[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] (\angVis:1) arc (\angVis:\angVis+180:1);
\draw[current plane,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand{\DrawLatitudeCircle}[2][2]{
\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);
}
\newcommand{\DrawOrbitCircle}[2][3]{
\OrbitPlane{\angEl-8}{#2} % orbit kippen!!!
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
% original
\draw[current plane] (\angVis:1) arc (\angVis:\angVis+180:1); % sichtbarkeit des vor der kugel befindlichen bereichs
\draw[current plane,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
} % achtung unten auch eine winkeländerung !!!???
%% 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}
%% some definitions
\def\R{4} % sphere radius
\def\rr{5} % orbit 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/.style={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}
\OrbitPlane[orbplanetwo]{\angEl-8}{\angAz} % dem orbit oben und unten winkel anpassen
\OrbitPlane[orbplane]{\angEl-8}{\angAz+60} % dem orbit oben und unten winkel anpassen
%######################################################################
%% draw xyplane and sphere
\fill[ball color=white!50!gray] (0,0) circle (\R); % 3D lighting effect
\draw[white] (0,0) circle (\R);
%% characteristic points
\path[orbplane] (\angBeta+10:\R/1) coordinate[mark coordinate,color=black] (P1); % works fine
\path[orbplane] (\angBeta+10:\rr/1) coordinate[mark coordinate,color=blue] (P2); % works fine
%#############################-problem-#########################################
\path[orbplanetwo] (\angPhi+50:\R/1) coordinate[mark coordinate,color=orange] (A1); % not at the expected position ???
\path[orbplanetwo] (\angBeta:\rr/1) coordinate[mark coordinate,color=orange] (A2); % not at the expected position ???
%##-wanted position of the orange dots-#####
\node at (-0.93,0) {o};
\node at (-1.15,0.05) {O};
%######################################################################
% Äquator, Orbit, Subspur etc.
%% draw meridians and latitude circles
\DrawLatitudeCircle[\R,yellow]{0} % equator
\DrawOrbitCircle[\rr,cyan]{\angAz+60} % orbit plane drehen !!!
\DrawOrbitCircle[\R,green]{\angAz+60} % orbit subspur !!!
\DrawOrbitCircle[\rr,red]{\angAz} % orbit plane drehen !!!
\DrawOrbitCircle[\R,red]{\angAz} % orbit subspur !!!
\end{tikzpicture}
\end{document}
我更愿意使用角度来设置坐标,因为我需要它们来做其他事情。谢谢你的帮助。
答案1
问题出在以下行(在\OrbitPlane
定义中):
\tikzset{#1/.style={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
\cost
在设置样式之前,、\sint
和宏不会展开,因此在您的代码中,\sinEl
和都设置为相同的样式。# 您应该使用键处理程序,为您提供\cosEl
orbplane
orbplanetwo
/.estyle
\tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
这\DrawOrbitCircle
与最近的 TikZ 版本不同:
\tikzset{current plane/.prefix style={scale=#1}}
由于/.prefix
处理程序在之后使用时似乎有一个错误/.estyle
,因此要修复它:
\newcommand{\DrawOrbitCircle}[2][3]{
\OrbitPlane{\angEl-8}{#2} % orbit kippen!!!
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
% original
\draw[scale=#1,current plane] (\angVis:1) arc (\angVis:\angVis+180:1); % sichtbarkeit des vor der kugel befindlichen bereichs
\draw[scale=#1,current plane,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
} % achtung unten auch eine winkeländerung !!!???