我想在旋转斜线后,按照代码中描述的方式将弧线与斜线相交。为什么红点不属于斜线?我希望我的问题足够清晰,便于理解。
\documentclass[12pt,a4paper]{article}
\usepackage{russ}
\usepackage[left=1cm,right=1cm,top=2cm,bottom=2cm]{geometry}
\usepackage{tikz} % Для рисования мега-картинок прямо здесь
\usepackage{rotating}
\usetikzlibrary{calc,intersections} % Читайте мануал в Bonus/Books on TeX/Pictures for TeX/PGF, а также http://www.texample.net/tikz/examples/all/
\colorlet{examplefill}{yellow!80!black}
\begin{document}
\begin{figure}
\begin{tikzpicture}[scale=3]
/cs/horizontal line through={(1,1)}
\path [name path=arc] (0.5cm,0) arc (0:90:0.5cm);
\draw (0,0) ellipse (0.7cm and 2.2cm);
\draw[name path=simple line] (-1,0) -- (1,0) coordinate (x axis);
\draw (0,-2.5) -- (0,2.5) coordinate (y axis);
\begin{turn}{50}
\draw[name path=sloped line] (-2.5,0) -- (2.5,0) coordinate (x axis);
\draw (0,-1.5) -- (0,1.5) coordinate (y axis);
\draw (0,0) ellipse (2cm and 1cm);
\end{turn}
\fill[red,name intersections={of=sloped line and arc, by=s}]
(s) circle (2pt) node[above=3] {a};
\end{tikzpicture}
\centering
\label{elliptic polarization}
\end{figure}
\end{document}
以及如何输出交点的坐标而不是a?!
答案1
为了产生旋转,您可以使用rotate
a 内的键scope
;然后sloped line
需要是一个全局路径名(我draw
在arc
路径中添加了 a 只是为了可视化目的);使用let
语法您可以得到交点的坐标:
\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usepackage{rotating}
\usetikzlibrary{calc,intersections}
\colorlet{examplefill}{yellow!80!black}
\begin{document}
\begin{tikzpicture}[scale=3]
/cs/horizontal line through={(1,1)}
\path[draw,name path=arc]
(0.5cm,0) arc (0:90:0.5cm);
\draw
(0,0) ellipse (0.7cm and 2.2cm);
\draw[name path=simple line]
(-1,0) -- (1,0) coordinate (x axis);
\draw
(0,-2.5) -- (0,2.5) coordinate (y axis);
\begin{scope}[rotate=50]
\draw[name path global=sloped line]
(-2.5,0) -- (2.5,0) coordinate (x axis);
\draw
(0,-1.5) -- (0,1.5) coordinate (y axis);
\draw
(0,0) ellipse (2cm and 1cm);
\end{scope}
\fill[red,name intersections={of=sloped line and arc, by=s}]
let \p1=(s)
in (s) circle (2pt) node[above=5,black] {(\x1,\y1)};
\end{tikzpicture}
\end{document}
上面的解决方案给出了以单位表示的点的坐标pt
;可以使用以下代码的变体以坐标系单位表示它们杰克在his answer
到访问 TikZ 坐标的逻辑值:
\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usepackage{rotating}
\usetikzlibrary{calc,intersections}
\colorlet{examplefill}{yellow!80!black}
\makeatletter
\newcommand\xcoord[2][center]{{%
\pgfpointanchor{#2}{#1}%
\pgfmathparse{\pgf@x/(\scalefactor*\pgf@xx)}%
\pgfmathprintnumber{\pgfmathresult}%
}}
\newcommand\ycoord[2][center]{{%
\pgfpointanchor{#2}{#1}%
\pgfmathparse{\pgf@y/(\scalefactor*\pgf@xx)}%
\pgfmathprintnumber{\pgfmathresult}%
}}
\makeatother
\pgfkeys{
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=3
}
\newcommand\labelcoord[2][]{%
\coordinate (aux) at (#2);
\node[#1] at (aux) {(\xcoord{aux},\ycoord{aux})}}
\def\scalefactor{3}
\begin{document}
\begin{tikzpicture}[scale=\scalefactor]
/cs/horizontal line through={(1,1)}
\path[draw,name path=arc]
(0.5cm,0) arc (0:90:0.5cm);
\draw
(0,0) ellipse (0.7cm and 2.2cm);
\draw[name path=simple line]
(-1,0) -- (1,0) coordinate (x axis);
\draw
(0,-2.5) -- (0,2.5) coordinate (y axis);
\begin{scope}[rotate=50]
\draw[name path global=sloped line]
(-2.5,0) -- (2.5,0) coordinate (x axis);
\draw
(0,-1.5) -- (0,1.5) coordinate (y axis);
\draw
(0,0) ellipse (2cm and 1cm);
\end{scope}
\fill[red,name intersections={of=sloped line and arc, by=s}]
(s) circle (2pt);
\labelcoord[above=4pt]{s};
\end{tikzpicture}
\end{document}