![为什么 $(O) + ($(X)!(O)!(D)$)$ 投影不正确](https://linux22.com/image/469482/%E4%B8%BA%E4%BB%80%E4%B9%88%20%24(O)%20%2B%20(%24(X)!(O)!(D)%24)%24%20%E6%8A%95%E5%BD%B1%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
% Draw the axes
\draw[->] (-1,0) -- (7,0) node[right] {$x$};
\draw[->] (0,-1) -- (0,7) node[above] {$y$};
% Define the coordinates
\coordinate (O) at (0,0);
\coordinate (X) at (1,5);
\coordinate (V) at (2,1);
\coordinate (D) at ($(O) + 5*(V)$); % 5 times the vector (2,1) added to the origin O
% Compute the projection using the dot product formula
\coordinate (P) at ($(O) + ($(X)!(O)!(D)$)$);
%\coordinate (P) at (2.8,1.4); % Adjusted to the projection point
% Draw the vectors and their projection
\draw[->, orange, thick] (O) -- (X) node[right] {$\vec{x}$};
\draw[->, green, thick] (O) -- (D) node[right] {Line L};
\draw[dashed, red, thick] (X) -- (P);
% Draw the projection point
\fill (P) circle (2pt) node[below left] {Projection};
% Add labels and other features if necessary
\end{tikzpicture}
\end{document}
请告诉我为什么我没有得到 x 在 L 线上的正确投影\coordinate (P) at ($(O) + ($(X)!(O)!(D)$)$)
当手动计算投影并用下面的线进行调整时,x 在线 L 上的投影是正确的
\coordinate (P) at (2.8,1.4); % Adjusted to the projection point