0

I'm trying to draw this exact image (attached)

Specific properties of the image:

  - angle QAP = 45 degrees (labeled theta)
  - ABCD is a square
  - P' is the 90 degree rotation of P along A (lying on CD)
  - Q and P can be anywhere in the lines BC and CD respectively 
  - AQ is the perpendicular bisector (cuts the middle) of line PP'

MANY Thank-you's for your help. Just recently starting learning this stuff.

enter image description here

2
  • You may be interested in tkz-euclide package.
    – user31034
    Sep 15 '19 at 20:28
  • I have removed the [geometry] tag, as that applies explicitly to the geometry package. Nov 22 '19 at 2:54
3

This is all straightforward with the calc library, where you can retrieve the coordinates with the let ... in syntax and use e.g. atan2 to compute angles and veclen to compute lengths that can be used in polar coordinates. In the following, a is the dimension of the square, and b the horizontal distance between Q and D.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[declare function={a=4;b=1;}]
 \draw (0,a) coordinate[label=above:$A$] (A) --
  (a,a) coordinate[label=above:$B$] (B) --
  (a,0) coordinate[label=below:$C$] (C) --
  (0,0) coordinate[label=below:$D$] (D) -- cycle;
 \path (b,0) coordinate[label=below:$Q$] (Q)
  let \p1=($(Q)-(A)$),\n1={atan2(\y1,\x1)+45} in
   ($(A)+(\n1:1)$) coordinate (aux) 
   (intersection cs:first line={(C)--(B)},second line={(A)--(aux)})
   coordinate[label=right:$P$] (P)
   let \p2=($(P)-(A)$),\n2={atan2(\y2,\x2)-90},\n3={veclen(\x2,\y2)}
   in ($(A)+(\n2:\n3)$) coordinate[label=below:$P'$] (P');
 \draw [blue] (Q) -- (A) -- (P) -- (P');  
 \fill foreach \X in {A,B,C,D,P,P',Q} {(\X) circle[radius=1.5pt]  };
\end{tikzpicture}
\end{document}

enter image description here

Of course, you may vary b.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\foreach \X in {0.2,0.25,...,2,1.95,1.9,...,0.25}
{\begin{tikzpicture}[declare function={a=4;b=\X;}]
 \path[use as bounding box] (-a,-0.5) rectangle (a+0.5,a+0.5);
 \draw (0,a) coordinate[label=above:$A$] (A) --
  (a,a) coordinate[label=above:$B$] (B) --
  (a,0) coordinate[label=below:$C$] (C) --
  (0,0) coordinate[label=below:$D$] (D) -- cycle;
 \path (b,0) coordinate[label=below:$Q$] (Q)
  let \p1=($(Q)-(A)$),\n1={atan2(\y1,\x1)+45} in
   ($(A)+(\n1:1)$) coordinate (aux) 
   (intersection cs:first line={(C)--(B)},second line={(A)--(aux)})
   coordinate[label=right:$P$] (P)
   let \p2=($(P)-(A)$),\n2={atan2(\y2,\x2)-90},\n3={veclen(\x2,\y2)}
   in ($(A)+(\n2:\n3)$) coordinate[label=below:$P'$] (P');
 \draw [blue] (Q) -- (A) -- (P) -- (P');  
 \fill foreach \X in {A,B,C,D,P,P',Q} {(\X) circle[radius=1.5pt]  };
\end{tikzpicture}}
\end{document}

enter image description here

1
  • I'm completely new to overleaf. No coding experience or anything so I really appreciate your help here. I'll look into everything you mentioned to be able to make my own stuff. Thanks AGAIN for your amazing help it is extremely appreciated!
    – marmarmar
    Sep 15 '19 at 20:44
1

With tkz-euclide v1.16 or 2.40 beta here

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}

\begin{tikzpicture}
  \tkzInit[xmax = 8] 
  \tkzDefPoint(8,0){C}
  \tkzDefPoint(0,0){D}
  \tkzDefSquare(D,C)
  \tkzGetPoints{B}{A}
  \tkzDrawSquare(D,C)
  \tkzGetRandPointOn[segment = C--D]{Q}
  \tkzDefPointBy[rotation= center A angle 45](Q)
  \tkzGetPoint{p}
  \tkzInterLL(A,p)(C,B) \tkzGetPoint{P}
  \tkzDefPointBy[rotation= center A angle -90](P)
  \tkzGetPoint{P'}
  \tkzDrawPoints(A,B,C,D,Q,P,P')
  \tkzLabelPoints(A,B,C,D,Q,P,P')
  \tkzDrawSegments(A,Q A,P P,P' D,P')
  \tkzLabelAngle[pos = 1.5](Q,A,P){$45^{\circ}$}
  \tkzMarkAngle[size = 1.8,mark = none,arc=l](Q,A,P)
  \end{tikzpicture}  
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.