I'm struggling to draw a diagram in tikz. I'm trying to do a simple illustration of a parallelogram inside an arbitrary quadrilateral.
I have the following code to place S halfway between O, and P.
Is there a way to do this? Ideally I would get a named coordinate that I can use for further drawing in the end
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{intersections, calc,through,backgrounds}
\begin{document}
\begin{tikzpicture}
%declare points OPQR at random locations
\coordinate[label=right:\textcolor{blue}{$O$}] (O) at ($(0,0) + 3*(rand, rand)$);
\coordinate[label=left:\textcolor{blue}{$P$}] (P) at ($(0,0) + -2*(rand, rand)$);
% I thought something like this would work, but it doesnt
%\coordinate[label=left:\textcolor{orange}{$S$}] (S) at ($0.5* ((O) - (P))$);
\draw[->, name path=A] (O) -- (P);
\end{tikzpicture}
\end{document}
I also tried:
(O) -- coordinate[midway](S) (P);
but when I tried to draw a line from S to another point I got an error that pgf didn't know any shapes by the name S
.
calc
:($(P)! 0.5!(Q)$)
is midway between P and Q.\path
in front of your last line of code? (btw: this is why we discourage using snippets of code, always use complete, compilable pieces of code.)\path
's left out (although i am intending to draw a line from each midpoint to each other midpoint now I have those worked out :P