I'm a beginner with TikZ and I'd like to show that a vector y can be decomposed as
How can I tell TikZ to draw a dashed line orthogonal to yp onto X and a vector ε orthogonal to X, starting at the origin? This is the code, but the projections are missing.
\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1},
extended line/.style={shorten >=-#1,shorten <=-#1},
extended line/.default=1cm]
\draw[thick,->] (-4.5,0) -- (4.5,0);
\draw[thick,->] (0,0) -- (0,4.5);
\coordinate (A) at (0,0);
\coordinate (B) at (-4,3);
\draw [extended line=0.5cm, <->] (A) -- (B)
node[pos=0.8,left=1em, font=\small]{$X$};
\draw [ ->] (0,0) -- (-2.6, 4.3) node[anchor=north east,font=\small] {$y$};
\end{tikzpicture}
\end{document}
Best Answer
One can project a coordinate, say,
(yn)
on the line between, say,(A)
and(B)
by using($(A)!(yn)!(B)$)
, as explained in the post linked by Marian G.. To get the picture, you may thus want to simply (meaning no intersections, explicit angles and so on) do