%
% konvex.tex -- template for standalon tikz images
%
% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
%
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usepackage{times}
\usepackage{txfonts}
\usepackage{pgfplots}
\usepackage{csvsimple}
\usetikzlibrary{arrows,intersections,math,calc,hobby}
\begin{document}
\def\skala{1}
\begin{tikzpicture}[>=latex,thick,scale=\skala]

\def\punkt#1{
	\fill[color=white] #1 circle[radius=0.05];
	\draw #1 circle[radius=0.05];
}

\begin{scope}[xshift=-3cm]
\coordinate (O) at (0,0);
\coordinate (A) at (-1,5);
\coordinate (B) at (3,2);
\draw[->] (O) -- (A);
\draw[->] (O) -- (B);
\begin{scope}
\clip (-2,0) rectangle (4,6);
\draw[color=red!40,line width=0.4pt] ($2*(B)-(A)$) -- ($2*(A)-(B)$);
\end{scope}
\draw[color=red,line width=1.5pt] (A) -- (B);
\punkt{(O)}
\punkt{(A)}
\punkt{(B)}
\node at (O) [below left] {$O$};
\node at (A) [above right] {$A$};
\node at (B) [above right] {$B$};
\node at ($0.5*(A)$) [left] {$\vec{a}$};
\node at ($0.5*(B)$) [below right] {$\vec{b}$};
\fill[color=white] ($0.6*(A)+0.4*(B)$) circle[radius=0.05];
\draw[color=red] ($0.6*(A)+0.4*(B)$) circle[radius=0.05];
\node[color=red] at ($0.6*(A)+0.4*(B)$) [above right] {$t\vec{a}+(1-t)\vec{b}$};
\end{scope}

\begin{scope}[xshift=4cm]
\coordinate (O) at (0,0);
\coordinate (A) at (-1,3);
\coordinate (B) at (2,5);
\coordinate (C) at (4,1);
\draw[->] (O) -- (A);
\draw[->] (O) -- (B);
\draw[->] (O) -- (C);
\fill[color=red!50,opacity=0.5] (A) -- (B) -- (C) -- cycle;
\draw[color=red,line width=1.5pt,opacity=0.7] (A) -- (B) -- (C) -- cycle;
\punkt{(O)}
\punkt{(A)}
\punkt{(B)}
\punkt{(C)}
\node at (O) [below left] {$O$};
\node at (A) [left] {$P_1$};
\node at (B) [above] {$P_2$};
\node at (C) [right] {$P_3$};
\node at ($0.5*(A)$) [left] {$\vec{p}_1$};
\node at ($0.3*(B)$) [right] {$\vec{p}_2$};
\node at ($0.5*(C)$) [below] {$\vec{p}_3$};
\fill[color=white] ($0.5*(C)+0.3*(A)+0.2*(B)$) circle[radius=0.05];
\draw[color=red] ($0.5*(C)+0.3*(A)+0.2*(B)$) circle[radius=0.05];
\node[color=red] at ($0.5*(C)+0.3*(A)+0.2*(B)$) [above] {$\displaystyle\sum_{t=1}^3 t_i\vec{p}_i$};
\end{scope}


\end{tikzpicture}
\end{document}

