# Without using intersection method, can we find the following vector component?

Given that two vectors, i.e., green and red ones. The objective is to find the blue one such that the resultant of the green and blue ones is parallel to the red one and with the same direction as the direction of the red vector.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-eucl}

\begin{document}

\begin{pspicture}[showgrid=true](4,3)
\pnode(0,0){O}
\pnode(4,3){A}
\pnode(0,2){B}
\pnode(A|B){C}
\psset{arrows=->}
\psline[linecolor=red](A)
\psline[linecolor=green](B)
\pstInterLL[PointName=none,PointSymbol=none]{B}{C}{O}{A}{D}
\psline[linecolor=blue](D|O)
\psline[linestyle=dashed,linecolor=gray,arrows=-](B)(D)(D|O)
\end{pspicture}

\end{document}


How to get the blue one in the simplest way without using intersection?

I want to apply the method in question for drawing the tension vector and its horizontal component as shown in the following figure (but such vectors have not been implemented yet):

• I'm so stupid, why did not I think of using triangle similarity as the given answers below. – kiss my armpit Sep 16 '12 at 2:31

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\begin{document}

\begin{pspicture}[showgrid=bottom](4,3)
\pnode(4,3){A}\pnode(0,2){B}
\psline[linecolor=red]{->}(A)
\psline[linecolor=green]{->}(B)
\pnode(!\psGetNodeCenter{A}
\psGetNodeCenter{B}
B.y A.y div A.x mul 0 ){D}
\psline[linestyle=dashed,linecolor=gray](B)(D|B)(D)
\psline[linecolor=blue]{->}(O)(D)
\end{pspicture}

\end{document}


the following works with the Beta version of pst-node (http://texnik.dante.de/tex/generic/pst-node/pst-node.tex) the coordinates of Nodes are available as N-<name>.x and N-<name>.y. Maybe that I'll change it to <name>.x and <name>.y

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\begin{document}

\begin{pspicture}[showgrid=bottom](4,3)
\pnode(4,3){A}
\pnode(0,2){B}
\psline[linecolor=red]{->}(A)
\psline[linecolor=green]{->}(B)
\pnode(!N-B.y N-A.y div N-A.x mul 0 ){D}
\psline[linestyle=dashed,linecolor=gray](B)(D|B)(D)
\psline[linecolor=blue]{->}(O)(D)
\end{pspicture}

\end{document}

• Is it a good idea for PSTricks core package to provide <nodename>.x and <nodename>.y out of the box without having to call \psGetNodeCenter{<nodename>}? Or perhaps we can turn on or off this feature by specifying an option that looks like \usepackage[NodeComponents=true]{pstricks} or \usepackage[NodeComponents=false]{pstricks} that is the default. – kiss my armpit Sep 15 '12 at 15:19
• that is a good idea! I uplaoded a beta and tried it successfully, see edited answer – user2478 Sep 15 '12 at 16:42
• Why did you need to use a prefix N- for the beta? Did you do this to avoid unknown side effects? For the final release, what does \psGetNodeCenter{} do when it is no longer needed explicitly? – kiss my armpit Sep 16 '12 at 11:18
• when using \rput{angle}(x,y){some node setting) you need \psGetNodeCenter{}. The default coordinates didn't take the translation and rotation into account. – user2478 Sep 16 '12 at 12:12
• In my opinion, if you are afraid about the possibility of name clashes with the PSTricks core, N-<node>.x might be shorten by <node>.X instead of <node>.x. What do you think? – kiss my armpit Sep 21 '12 at 6:10

Here is a TikZ solution:

\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[green] (0,0) -- (0,2) coordinate (b);
\draw[red] (0,0) -- (4,3) coordinate (a);
\draw[blue] let \p1=(a), \p2=(b) in (0,0) -- (\y2/\y1*\x1,0);
\end{tikzpicture}
\end{document}


I complement what has been answered by Herbert Voss. If the vector tails are not on the origin then the calculation must include the tail vectors as follows.

With the latest PSTricks core,

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\begin{document}

\begin{pspicture}[showgrid=bottom](-1,-2)(4,3)
\pnode(-1,-2){O}
\pnode(4,3){A}
\pnode(0,2){B}
\psline[linecolor=red]{->}(O)(A)
\psline[linecolor=green]{->}(O)(B)
\pnode(!N-B.y N-O.y sub N-A.y N-O.y sub div N-A.x N-O.x sub mul N-O.x add 0){C}
\psline[linestyle=dashed,linecolor=gray](B)(C|B)(C)
\psline[linecolor=blue]{->}(O)(C)
\end{pspicture}

\end{document}