Does anybody have an idea how to generate perpendicular lines to an arbitrary line in Tikz?
As you can see, in the following:
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{quotes,angles}
\usepackage{tikz-3dplot}
\begin{tikzpicture}
\draw [black, thick,fill=white] (0.0,0.0) circle [radius=0.75];
\draw [->] (0,0) -- (cos{45}*0.75,sin{45}*0.75);
\node at (0.1,0.4) {{ ${r}$}};
\draw [->,thick] (-3,0) -- (-1.75,0);
\draw [thick] (-1.75,0) -- (-0.5,0.0);
\draw [thick,dashed] (-0.75,0) -- (0,0);
\draw [thick,dashed] (0.0,0.0) -- (0.75,0.0);
\draw [->,thick] (0.5,0.0) -- (1.75,0.0);
\draw [thick, dashed] (0.0,0.0) -- (0.0,0.75);
\draw [->,thick] (0.0,0.4) -- (0.0,2);
\node at (1.9,0.0) {{\large $z$}};
\node at (0.0,2.1) {{\large $y$}};
\draw [thick] (-2.3,-0.25) -- (-2.3,0.25);
\draw [thick] (-2.2,-0.25) -- (-2.2,0.25);
\path
(1,0) coordinate (a)
-- (0,0) coordinate (O)
-- (1,1) coordinate (b)
pic["$\theta$",draw=red,<->,angle eccentricity=1.35,angle radius=0.4cm] {angle=a--O--b};
\end{tikzpicture}
I've had no trouble in creating perpendicular lines to the $x$-axis. I'm now trying to do something similar to the line passing through the origin of the following diagram
\begin{tikzpicture}
\draw [->,thick] (-3.5,0)--(3.5,0) node[right, at end] {\large$x$};
\draw [->,thick] (0,3.5)--(0,-3.5)node[right, at end] {\large$y$};;
\draw[thick] (-3,-2) -- (3,2);
\path
(0,3.5) coordinate (a)
-- (0,0) coordinate (O)
-- (3,2) coordinate (b)
pic["$\theta_1$",draw=red,<->,angle eccentricity=1.2,angle radius=1cm] {angle=b--O--a};
\draw [thick] (3,-2)--(-3,2);
\path
(0,3.5) coordinate (e)
-- (0,0) coordinate (O)
-- (-3,2) coordinate (f)
pic["$\theta_1$",draw=red,<->,angle eccentricity=1.2,angle radius=1cm] {angle=e--O--f};
\draw[->,very thick] (-3,-2)--(-1.5,-1);
\node at (-1.5,-1.3) {{$\mathbf{l}$}};
\end{tikzpicture}
Any ideas?!
Best Answer
Loading the
calc
library, you can draw perpendicular lines. I made the line dashed for the example, so you see it better.Output
Code