# Drawing perpendicular lines, filling areas

I still have some trouble with perpendicular lines. This is the figure I'd like to replicate

This is my MWE

\documentclass[12pt,a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{calc}

\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[extended line,thick,->] (-3.5,0) -- (4.5,0) node[anchor=north west] {\small spot 0};
\draw[extended line,thick,->] (0,-3.5) -- (0,4.5) node[anchor=south east] {\small spot 1};

\coordinate (A) at (0,4);
\coordinate (B) at (4,0);

\draw (A) -- (B)
node[pos=0.7,above=0.5em, font=\small]{$\Delta$};

\coordinate (C) at (0,0);
\coordinate (D) at (1.5,1.8);
\draw [thick, ->](C) -- (D)
node[pos=0.7,above=0.5em, font=\small]{$\Phi$};

\draw [dashed] (D)--(B) node[anchor= south west, font=\small]{$\delta^{0}$};

\draw (-3.5,-2)--(0,0)--(3.5,-2.5);

\fill[blue!10,fill opacity=0.3] (5,4.5) rectangle (0,0);

\end{tikzpicture}

\end{document}


I tried to add a coordinate on the "cone" and use the calcsyntax to draw a perpendicular line, but it doesn't work. Should I use arcto fill the cone? Thank you for your time.

Something like this?

\documentclass[12pt,a4paper]{article}

\usepackage{tikz}

\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[extended line,thick,->] (-3.5,0) -- (4.5,0) node[anchor=north west] {\small spot 0};
\draw[extended line,thick,->] (0,-3.5) -- (0,4.5) node[anchor=south east] {\small spot 1};

\shade[upper right=gray!20,lower left=gray,fill opacity=0.3] (5,4.5) rectangle (0,0);

\coordinate (A) at (0,4);
\coordinate (B) at (4,0);

\draw (A) -- (B)
node[pos=0.7,above=0.5em, font=\small]{$\Delta$};

\coordinate (C) at (0,0);
\coordinate (D) at (1.3,1.8);
\draw [thick, ->](C) -- (D)
node[pos=0.7,above=0.5em, font=\small]{$\Phi$};

\draw let \p1=($(D)-(C)$), \n1={atan2(\y1,\x1)-90}, \n2={\n1-120} in
(\n1:4) coordinate (aux) -- (C) -- (\n2:4) arc(\n2:\n1:4);
\draw [dashed] (D)--(B) node[anchor= south west, font=\small]{$\delta^{0}$}
-- (intersection cs:first line={(B)--($(B)!3cm!90:(D)$)},
second line={(C)--(aux)});
\end{tikzpicture}
\end{document}


• thank you, @marmot, anyway I also wanted to add a perpendicular line from B to the right side of the cone. may I ask you how can I do? – Nenne May 10 at 14:53
• @Nenne Oh, sorry. I missed that! The line is drawn via \draw [dashed] (D)--(B) node[anchor= south west, font=\small]{$\delta^{0}$} -- (intersection cs:first line={(B)--($(B)!3cm!90:(D)$)}, second line={(C)--(aux)});  and added to the code. The orthogonal line is (B)--($(B)!3cm!90:(D)$) and it is only drawn to the cone, hence intersection cs:. – user121799 May 10 at 15:03
• that's perfect, as usual. since I wanted to add also the label X on the cone, how can I change its color from gray to black? I added node[anchor=north, font=\small] {$X$} after your code \draw let \p1=($(D)-(C)$), \n1={atan2(\y1,\x1)-90}, \n2={\n1-120} in [upper right=blue,lower left=blue!20,fill opacity=0.3,shading angle=\n1+60] (\n1:4) coordinate (aux) -- (C) -- (\n2:4) arc(\n2:\n1:4). – Nenne May 10 at 15:33
• Sorry, I used blue instead of gray, anyway I want the label in black. – Nenne May 10 at 15:33
• @Nenne \draw let \p1=($(D)-(C)$), \n1={atan2(\y1,\x1)-90}, \n2={\n1-120} in [upper right=gray,lower left=gray!20,fill opacity=0.3,shading angle=\n1+60] (\n1:4) coordinate (aux) -- (C) -- (\n2:4) arc(\n2:\n1:4) node[anchor=north, font=\small,text=black,opacity=1] {$X$} ; i.e. also set the opacity to 1. (My bad.) – user121799 May 10 at 15:38

an another approximation to desired image (to a certain extent is similar to @marmot answer):

\documentclass[12pt, tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
calc,
backgrounds,
intersections,

\begin{document}
\begin{tikzpicture}[
> = Straight Barb,
dot/.style = {circle,inner sep=1pt,fill,label={#1},name=#1},
every pin/.style = {pin edge={<-,line width=0.5pt,black},},
font = \small
]

\draw[->] (-4,0.0) -- (6,0) node[below left] {spot 0};
\draw[->] (0,-3.5) -- (0,5) node[below left] {spot 1};

\coordinate (A) at (0,4);
\coordinate (B) at (4,0);

\draw       (A) -- node[coordinate,pin=45:$\Delta$] {} (B) ;

\coordinate (C) at (0,0);
\coordinate (D) at (1.5,1.8);
\draw[->](C) -- (D) node[left]  {$\Phi$};

\draw[dashed] (D)--(B) node[above right]{$\delta^{0}$};
\draw[name path=A]   (210:3.3) -- (0,0) -- (330:3.3);
\begin{scope}[on background layer]
\fill[top color=blue!30,bottom color=blue!5]
(0,0) -- (210:3.3) arc (210:330:3.3) -- (0,0);
\fill[lower left=blue!30, upper right=blue!5]
(4.5,4.5) rectangle (0,0);
\end{scope}
\path[name path=B]   (B) -- ($(B)!22mm!90:(A)$);
\draw[name intersections={of=A and B,by=x},
dashed]       (x) node[below] {$x^0$} -- (B);
\end{tikzpicture}
\end{document}


off-topic: use of extended line as is defined in your mwe can spill a line out of bounding box and with this cause unexpected problems. also positions of nodes is not on the end of such drawn lines but at given end coordinates. therefore i didn't use this line style.