5

Using the idea of @AboAmmar in the question # 374104 , in, I made the next drawing:

enter image description here

\documentclass[12pt]{article}    
\usepackage[T1]{fontenc}    
\usepackage[latin1]{inputenc}     
\usepackage[brazil]{babel}    
\usepackage{tikz}    
\begin{document}

\begin{tikzpicture}[baseline=(n.base),decoration=bumps]    
\node[draw,ellipse,decorate](n){\textbf{Solução}};    
\end{tikzpicture}\\

\bigskip

\tikzset{     
  tr/.pic={       
    \draw[pattern=dots] (0,0) -- (0,4cm) -- (30:2cm) -- cycle;       
    \node at ($(0,0)!1.2!(30:2cm)$) {#1};
  }
}

\begin{center}    
\begin{tikzpicture}[scale=1]    
\path pic[rotate=  0]  at (4,0) {tr=S};    
\path pic[rotate= 90]  at (4,0) {tr=R};    
\path pic[rotate=-90]  at (0,4) {tr=Q};    
\path pic[rotate=180]  at (0,4) {tr=P};    
\path pic[rotate= 270]  at (0,0) {tr=};    
\path pic[rotate= -180]  at (4,4) {tr=};    
\path pic[rotate= -270]  at (4,4) {tr=};    
\path pic[rotate= -0]  at (0,0) {tr=};    
\end{tikzpicture}    
\end{center}

\end{document}

But, I can't draw the line segment joining P to S. How do?

1
  • I am not able to make your example compile, are you missing any libraries or packages?
    – Moriambar
    Jun 9, 2017 at 21:17

3 Answers 3

4
\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}

\begin{document}

\bigskip
\tikzset{
  tr/.pic={
    \draw[pattern=dots] (0,0) -- (0,4cm) -- (30:2cm) -- cycle;
    \draw[pattern=dots] (0,0) -- (0,4cm) -- ++(210:2cm) -- cycle;
    \node at ($(0,0)!1.2!(30:2cm)$) {#1};
    \coordinate (#1) at (30:2cm); } }

\begin{tikzpicture}[scale=1]
  \path pic[rotate= 0] at (4,0) {tr=S};
  \path pic[rotate= 90] at (4,0) {tr=R};
  \path pic[rotate=-90] at (0,4) {tr=Q};
  \path pic[rotate=180] at (0,4) {tr=P};
  \draw (P) -- (S);
\end{tikzpicture}

\end{document}

enter image description here

3
  • 2
    Nice, but what about the [PS] segment, then ?
    – marsupilam
    Jun 9, 2017 at 23:31
  • I overlooked that because his question was not well formatted at the beginning. I added the line PS similar as you in my answer for the sake of completeness.
    – hzhr
    Jun 10, 2017 at 6:06
  • marsupilam, the design is about solving the problem: Congruent right triangle are erected to the sides of the square, facing outward and inward alternately as shown in the question # 374104. The problem is to show that the points P, Q, R and S are collinear.
    – benedito
    Jun 11, 2017 at 21:57
7

I tried an answer interpreting your text

\documentclass[12pt]{article}

\usepackage[T1]{fontenc}    

\usepackage[latin1]{inputenc}   

\usepackage[brazil]{babel} 

\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations}

\begin{document}

\tikzset{%
 tr/.pic={%
 \draw[pattern=dots] (0,0) -- (0,4cm) -- (30:2cm) -- cycle;
 \node at ($(0,0)!1.2!(30:2cm)$) {#1};
  }
}

    \begin{center}

\begin{tikzpicture}[scale=1]

\path pic[rotate=  0]  at (4,0) {tr=S};

\path pic[rotate= 90]  at (4,0) {tr=R};

\path pic[rotate=-90]  at (0,4) {tr=Q};

\path pic[rotate=180]  at (0,4) {tr=P};

\path pic[rotate= 270]  at (0,0) {tr=};

\path pic[rotate= -180]  at (4,4) {tr=};

\path pic[rotate= -270]  at (4,4) {tr=};

\path pic[rotate= -0]  at (0,0) {tr=};

\draw (-1.74,3) -- (5.74,1);

\end{tikzpicture}

\end{center}

\end{document}

enter image description here

0
7

A simple automatic solution using the coordinate key. Without knowing the coordinates of points P or S, the rec picture will name these points pointP and pointS, respectively. Then a simple draw command will connect the two points. Note also that the rec picture now draws rectangles.

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc, patterns}
\begin{document}

\tikzset{
 rec/.pic={
  \draw [pattern=dots](0,0) --(30:2cm)coordinate(point#1) --(0,4cm) --++(210:2cm) --cycle;
  \node at ($(0,0)!1.2!(35:2cm)$) {#1}; 
 } 
}

\begin{tikzpicture}[scale=1]
  \draw (0,0) rectangle (4,4);  
  \path pic[rotate=  0] at (4,0) {rec=S};
  \path pic[rotate= 90] at (4,0) {rec=R};
  \path pic[rotate=-90] at (0,4) {rec=Q};
  \path pic[rotate=180] at (0,4) {rec=P};
  \draw (pointS) -- (pointP);
\end{tikzpicture}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .