考虑以下代码:
\documentclass[convert = false]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[
every label/.append style = {font = \scriptsize},
dot/.style = {inner sep = +0pt, shape = circle,
draw = black, label = {#1}},
small dot/.style = {minimum size = .05cm, dot = {#1}},
big dot/.style = {minimum size = .1cm, dot = {#1}}
]
\coordinate (O) at (0,0);
\draw[name path = ell] (O) ellipse (2cm and 1cm);
\path[name path = line1] (O) -- (135:3cm);
\path[name intersections = {of = line1 and ell, by = P1}];
\node[font = \tiny, fill = black, big dot = {above: \(P_1\)}] (P1) at (P1) {};
\draw (P1) -- ($(P1)!1cm!-90:($(intersection-1)!1cm!(intersection-2)$)$);
\draw (O) -- (P1);
\path[name path = circ] (P1) circle [radius = 1bp];
\draw[name intersections = {of = circ and ell}] (P1) --
($(intersection-1)!1cm!(intersection-2)$);
\end{tikzpicture}
\end{document}
在这篇文章中TikZ:为什么找不到第二个路口?,Jake 帮助我在只有 1 个交叉点的情况下使用交叉点。但是,尽管我收到不存在的错误,但intersections-2
情节是正确的。
如果我改为intersection-2
,P1
情节是不正确的,但没有编译错误。
\draw (P1) -- ($(P1)!1cm!-90:($(intersection-1)!1cm!(P1)$)$);
那么,我怎样才能同时获得两条线的最佳效果:一条线垂直于射线OP1
,并且没有编译错误?
答案1
(O)
要绘制一条与从到 的直线垂直的直线(P1)
,您根本不需要交点。您可以简单地使用calc
旋转线的语法:
\draw [red] (P1) -- ($(P1)!1cm!-90:(O)$);