Tikz:使用坐标进行计算

Tikz:使用坐标进行计算

受到这个问题的启发如何画一条过一个点并与另一个点平行的线?我正在尝试用坐标进行一些算术运算。下面的代码不起作用,但我希望稍加修改就可以了。基本上

  • 在中%Q1,我尝试将向量 (1,1) 添加到 (x) 以获得 (y)
  • 在 中%Q2,我尝试将一个由距离 1.5 和角度 270° 定义的矢量添加到 (x) 以获得 (y)
  • %Q3与另一个上下文相同%Q2(可能语法也相同)

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,patterns,angles,quotes}

\begin{document}
\begin{center}
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,label={$#1$},name=#1},
  extended line/.style={shorten >=-#1,shorten <=-#1},
  extended line/.default=1cm]

\node [dot=x] at (0,0) {};
% --------
%\node [dot=y] at (x) +($(1,1)$) {};        %Q1
%\node [dot=y] at (x) +($(1.5;270)$) {};    %Q2
\node [dot=y] at (x) ++(1.5;270) {};        %Q2
% --------
\draw [extended line=0.5cm] (x) -- (y);
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[]

\ccordinate (a) at (0,0);
\ccordinate (b) at (a)+(2;45);              %Q3
\draw [extended line=0.5cm] (a) -- (b);
\end{tikzpicture}
\end{center}

\end{document}

答案1

感谢评论,这里是答案:

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,patterns,angles,quotes}

\begin{document}
\begin{center}
\begin{tikzpicture}[x=1cm,y=1cm,
  dot/.style={circle,inner sep=1pt,fill,label={$#1$},name=#1},
  dott/.style={circle,inner sep=1pt,fill},
  extended line/.style={shorten >=-#1,shorten <=-#1},
  extended line/.default=1cm]

\node [dot=x] at (0,0) {};
\node [dot=y] at ($(x)+(45:2)$) {};
\node [dot=z] at ($(x)+(1,0)$) {};
\draw [extended line=0.5cm] (x) -- (y);
\draw [extended line=0.5cm] (x) -- (z);

\coordinate (a) at (2,0);
\coordinate (b) at ($(a)+(-45:1)$);
\draw [extended line=0.5cm] (a) -- (b);
\node[dott] at (a) {};
\node at (a) [above right = 0.7mm of a] {$a$};
\node[dott] at (b) {};
\node at (b) [above] {$b$};

\end{tikzpicture}
\end{center}

\end{document}

在此处输入图片描述

相关内容