我试图在 O 的垂直线与 AB 线相交的点上绘制垂直符号。但我无法实现。我尝试通过简单的绘制,因为我使用 pgfplots(您可以在 MWE 中看到,我曾尝试过 tkz-euclide 但徒劳无功)。请帮忙。
梅威瑟:
\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tkz-euclide} % loads TikZ and tkz-base
\usetkzobj{angles} % important you want to use angles
\usepackage{pgfplots}
\usetikzlibrary{angles,quotes,calc}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
% legend pos=outer north east,
xmin=0, xmax=3, ymin=0, ymax=3,
xlabel = {X}, ylabel = {Y},
ytick=\empty,
xtick=\empty,
clip=false,
grid = major, axis lines = middle ,
axis line style={gray}
]
\def\uu{\large $\hat{u}$};
\def\vu{\large $\hat{v}$};
\def\au{\large $\vec{a}$};
\def\bu{\large $\vec{b}$};
\def\cu{\large $\vec{c}$};
\coordinate (o) at (0,0);
\coordinate (a) at (1, 2);
\coordinate (b) at (2, 0.5);
\coordinate (u) at (0.26, 0.52);
\coordinate (v) at (0.52, 0.13);
\coordinate (i) at (0.5,0);
\coordinate (j) at (0,0.5);
% \draw pic[draw,fill=cyan!30,angle radius=1.6cm,"$\beta$" shift={(9mm,2mm)}] {angle=i--o--u};
% \draw pic[draw,fill=red!30,angle radius=1.2cm,"$\alpha$" shift={(6mm,2mm)}] {angle=i--o--v};
\draw pic[draw,fill=green!30,angle radius=1cm,"$\theta$" shift={(1mm,1mm)}] {angle=b--o--a};
\draw[line width=2pt,blue,-stealth](o)--(a) node[anchor=south west, xshift=-2mm, yshift=-1mm]{A}; % vector a
\draw[line width=2pt,red,-stealth](o)--(b) node[anchor=south west, xshift=-1mm, yshift=-2mm]{B}; % vector b
\draw[line width=2pt,green!60!black,-stealth](a)--(b); % vector c
\draw[line width=2pt,blue,-stealth](o)--(u) node[anchor=south east, yshift=-2mm]{\uu};
\draw[line width=2pt,red,-stealth](o)--(v) node[anchor=south west, xshift=-2mm]{\vu};
\draw[line width=1.5pt,-stealth](o)--(i) node[below=6mm, anchor=south east]{$\hat{i}$};
\draw[line width=1.5pt,-stealth](o)--(j) node[anchor=south east]{$\hat{j}$};
% perpendicular line
% https://tex.stackexchange.com/questions/19348/how-to-draw-a-line-passing-through-a-point-and-perpendicular-to-another
\draw ($(a)!(o)!(b)$) -- (o);
\node [above] at (0.51, 1.28) {$\vec{a}$};
\node [below] at (1.42, 0.35) {$\vec{b}$};
% BELOW LINES DO NOT ADD SYMBOL AT RIGHT PLACE.
\coordinate (X) at (o |- a);
\draw ($(X)!5pt!(o)$) -| ($(X)!5pt!(a)$);
\end{axis}
% BELOW IS DRAWING AT WRONG PLACE
% \tkzDefPoint(0,0){O}
% \tkzDefPoint(1,2){A}
% \tkzDefPoint(2,0.5){B}
% \tkzDefPointBy[projection=onto B--A](O) \tkzGetPoint{H};
% \tkzMarkRightAngle[fill=blue!20,size=.5](O,H,B);
\end{tikzpicture}
\end{document}
答案1
像这样吗?
\documentclass{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\usetikzlibrary{angles,quotes,calc}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
% legend pos=outer north east,
xmin=0, xmax=3, ymin=0, ymax=3,
xlabel = {X}, ylabel = {Y},
ytick=\empty,
xtick=\empty,
clip=false,
grid = major, axis lines = middle ,
axis line style={gray}
]
\def\uu{\large $\hat{u}$};
\def\vu{\large $\hat{v}$};
\def\au{\large $\vec{a}$};
\def\bu{\large $\vec{b}$};
\def\cu{\large $\vec{c}$};
\coordinate (o) at (0,0);
\coordinate (a) at (1, 2);
\coordinate (b) at (2, 0.5);
\coordinate (u) at (0.26, 0.52);
\coordinate (v) at (0.52, 0.13);
\coordinate (i) at (0.5,0);
\coordinate (j) at (0,0.5);
% \draw pic[draw,fill=cyan!30,angle radius=1.6cm,"$\beta$" shift={(9mm,2mm)}] {angle=i--o--u};
% \draw pic[draw,fill=red!30,angle radius=1.2cm,"$\alpha$" shift={(6mm,2mm)}] {angle=i--o--v};
\draw pic[draw,fill=green!30,angle radius=1cm,"$\theta$" shift={(1mm,1mm)}] {angle=b--o--a};
\draw[line width=2pt,blue,-stealth](o)--(a) node[anchor=south west, xshift=-2mm, yshift=-1mm]{A}; % vector a
\draw[line width=2pt,red,-stealth](o)--(b) node[anchor=south west, xshift=-1mm, yshift=-2mm]{B}; % vector b
\draw[line width=2pt,green!60!black,-stealth](a)--(b); % vector c
\draw[line width=2pt,blue,-stealth](o)--(u) node[anchor=south east, yshift=-2mm]{\uu};
\draw[line width=2pt,red,-stealth](o)--(v) node[anchor=south west, xshift=-2mm]{\vu};
\draw[line width=1.5pt,-stealth](o)--(i) node[below=6mm, anchor=south east]{$\hat{i}$};
\draw[line width=1.5pt,-stealth](o)--(j) node[anchor=south east]{$\hat{j}$};
% perpendicular line
% https://tex.stackexchange.com/questions/19348/how-to-draw-a-line-passing-through-a-point-and-perpendicular-to-another
\draw ($(a)!(o)!(b)$) coordinate(aux0) -- (o);
\draw ($(aux0)!2mm!(b)$) -- ++ ($($(aux0)!2mm!(o)$)-(aux0)$) -- ($(aux0)!2mm!(o)$);
\node [above] at (0.51, 1.28) {$\vec{a}$};
\node [below] at (1.42, 0.35) {$\vec{b}$};
% BELOW LINES DO NOT ADD SYMBOL AT RIGHT PLACE.
\end{axis}
\end{tikzpicture}
\end{document}
答案2
可能有更简单的方法,但我看不懂法语。
\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tkz-euclide} % loads TikZ and tkz-base
\usetkzobj{angles} % important you want to use angles
\usepackage{pgfplots}
\usetikzlibrary{angles,quotes,calc}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
% legend pos=outer north east,
xmin=0, xmax=3, ymin=0, ymax=3,
xlabel = {X}, ylabel = {Y},
ytick=\empty,
xtick=\empty,
clip=false,
grid = major, axis lines = middle ,
axis line style={gray}
]
\def\uu{\large $\hat{u}$};
\def\vu{\large $\hat{v}$};
\def\au{\large $\vec{a}$};
\def\bu{\large $\vec{b}$};
\def\cu{\large $\vec{c}$};
\coordinate (o) at (0,0);
\coordinate (a) at (1, 2);
\coordinate (b) at (2, 0.5);
\coordinate (u) at (0.26, 0.52);
\coordinate (v) at (0.52, 0.13);
\coordinate (i) at (0.5,0);
\coordinate (j) at (0,0.5);
% \draw pic[draw,fill=cyan!30,angle radius=1.6cm,"$\beta$" shift={(9mm,2mm)}] {angle=i--o--u};
% \draw pic[draw,fill=red!30,angle radius=1.2cm,"$\alpha$" shift={(6mm,2mm)}] {angle=i--o--v};
\draw pic[draw,fill=green!30,angle radius=1cm,"$\theta$" shift={(1mm,1mm)}] {angle=b--o--a};
\draw[line width=2pt,blue,-stealth](o)--(a) node[anchor=south west, xshift=-2mm, yshift=-1mm]{A}; % vector a
\draw[line width=2pt,red,-stealth](o)--(b) node[anchor=south west, xshift=-1mm, yshift=-2mm]{B}; % vector b
\draw[line width=2pt,green!60!black,-stealth](a)--(b); % vector c
\draw[line width=2pt,blue,-stealth](o)--(u) node[anchor=south east, yshift=-2mm]{\uu};
\draw[line width=2pt,red,-stealth](o)--(v) node[anchor=south west, xshift=-2mm]{\vu};
\draw[line width=1.5pt,-stealth](o)--(i) node[below=6mm, anchor=south east]{$\hat{i}$};
\draw[line width=1.5pt,-stealth](o)--(j) node[anchor=south east]{$\hat{j}$};
% perpendicular line
% https://tex.stackexchange.com/questions/19348/how-to-draw-a-line-passing-through-a-point-and-perpendicular-to-another
\coordinate (X) at ($(a)!(o)!(b)$);
\draw (X) -- (o);
\node [above] at (0.51, 1.28) {$\vec{a}$};
\node [below] at (1.42, 0.35) {$\vec{b}$};
% ADD PERPENDICULAR SYMBOL
\coordinate (Xo) at ($(X)!5pt!(o)$);
\coordinate (Xb) at ($(X)!5pt!(b)$);
\draw (Xo) -- ($(Xo)!5pt!-45:(Xb)$) -- (Xb);
\end{axis}
% BELOW IS DRAWING AT WRONG PLACE
% \tkzDefPoint(0,0){O}
% \tkzDefPoint(1,2){A}
% \tkzDefPoint(2,0.5){B}
% \tkzDefPointBy[projection=onto B--A](O) \tkzGetPoint{H};
% \tkzMarkRightAngle[fill=blue!20,size=.5](O,H,B);
\end{tikzpicture}
\end{document}