TransWikia.com

Draw some circle on top of other circles

TeX - LaTeX Asked by masrosid on May 5, 2021

I wanted to draw some circle like this

circles

I have created 3 circles, but I think there would be better solution. What if the circles are more than 6? How do I draw that?

    documentclass[10pt]{standalone}
    usepackage{tkz-euclide}
    
    begin{document}
    
    pgfmathsetmacro{radius}{1}
    begin{tikzpicture}
       tkzDefPoints{0/0/A,2*radius/0/B}
       tkzDefTriangle[equilateral](A,B)    tkzGetPoint{C}
       tkzDefPoint(0,-radius){D}
       tkzDefPoint(2*radius,-radius){E}
       tkzDefShiftPoint[B](30:radius){F}
       tkzDefShiftPoint[C](30:radius){G}
       tkzDefShiftPoint[C](150:radius){H}
       tkzDefShiftPoint[A](150:radius){I}
       
       
       tkzDrawCircles[R](A,radius cm B,radius cm C,radius cm)
        
        tkzDrawSegments(D,E F,G H,I)
      
     end{tikzpicture} 
     end{document}

One Answer

I leave you an easy solution made with tikz instead of tkz-euclide. With a couple of nested foreach you have it. You just have to change the num parameter to change the number of rows in the drawing.

documentclass[tikz,border=2mm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}[line cap=round]
  defnum{4} % number of rows
  defr  {1} % circle radius
  foreachi in {1,...,num}
  {
    pgfmathsetmacroy{-sqrt(3)*r*i}
    foreachj in {1,...,i}
    {
      pgfmathsetmacrox{r*(2*j-i)}
      draw (x,y) circle (r);
      fill (x,y) circle (0.1*r);
      coordinate (C-j-i) at (x,y);
    }
  }
  draw ($(C-1-1)   +(150:r)$) -- ($(C-1-num)   +(150:r)$);
  draw ($(C-1-1)   + (30:r)$) -- ($(C-num-num)+ (30:r)$);
  draw ($(C-1-num)+(270:r)$) -- ($(C-num-num)+(270:r)$);
end{tikzpicture}
end{document}

enter image description here

Correct answer by Juan Castaño on May 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP