当前位置:网站首页>Tikz learning notes (IV) further exploration of circle and complex geometry

Tikz learning notes (IV) further exploration of circle and complex geometry

2022-06-22 07:07:00 zorchp

Write it at the front

I introduced some basic graphics , The marking and intersection of the graph and some contents of the cycle , This time with the previous knowledge , You can create more complex graphics . Now let's introduce a simple drawing technique , That is, according to the given point ( center of a circle ) And any point on the circle to draw the circle . Then we can draw some complicated figures according to this technique .

By reading this article , You should be able to draw the following figure

And then draw some more complicated geometric figures , However, the method introduced here is still complex , And then you can go through tikz-euclide Package for quick rendering .

Given the length of two points as radius, make a circle ( arc )

This is a method often used in drawing with ruler and gauge , This is especially true when taking an arc of a given length , So let's see what happens here tikz The basic syntax for drawing in

\path [name path=o1] 
let 
	\p1=($ (A) - (B) $), 
	\n1={
    veclen(\x1, \y1)}
in 
	(O) circle (\n1);

The above code means :

  1. Mark a circle o1;
  2. take A And B A vector formed by two points , Write it down as \p1;
  3. utilize tikz Engine veclen Function calculation AB The length of , And remember to \n1;
  4. Mark ( No drawing ) With O For the center of a circle , AB A circle with a length of radius .

Through this code , It is convenient to draw the length given by two points as the radius , A circle centered on a given point .

similarly , If you need to draw an arc , You only need to modify the last line of code to achieve , Examples are as follows

\path [name path=o1] 
let 
	\p1=($ (A) - (B) $), 
	\n1={
    veclen(\x1, \y1)}
in 
	(O) arc (0:90:1);

The main function used here is still \path, So it will not be drawn , If you need to draw , Then you can add [draw] Parameters , Or use it directly \draw Function to complete .

A simple example : Drawing method of drawing regular pentagon with ruler and gauge

design sketch :

The code and comments are as follows : See my previous article for detailed drawing steps TikZ Drawing examples —— A ruler makes a picture : An approximate drawing of a regular pentagon inscribed in a circle _zorchp-CSDN Blog _ Draw a regular pentagon with a ruler and gauge .

\documentclass[tikz,border=3pt]{standalone}
\usetikzlibrary{calc}
\usetikzlibrary{intersections,through}

\begin{document}
    \begin{tikzpicture}[]
        % AB, CD Is the vertical centerline of the circle 
        \coordinate [label=below left:$A$] (A) at (0,0);
        \coordinate [label=below right:$B$] (B) at (4,0);
        \coordinate [label=above left:$C$] (C) at (2,2);
        \coordinate [label=below right:$D$] (D) at (2,-2);
        \coordinate [label=below right:$O$] (O) at (2,0);
        \draw [name path=o] (O) circle (2);
        \draw [densely dashed,-latex,name path=AB] ($(A)!-.1!(B)$) -- ($(A)!1.1!(B)$);
        \draw [densely dashed,latex-,name path=CD] ($(C)!-.1!(D)$) -- ($(C)!1.1!(D)$);
        \coordinate [label=below:$H$] (H) at ($(O)!.5!(B)$);
        %  Mark the arc segment 
        \path [name path=o1] 
        let 
            \p1=($ (H) - (C) $), 
            \n2={veclen(\x1, \y1)}
        in 
            (H) circle (\n2);
        %  Find the intersection G
        \path [name intersections={of=o1 and AB}] 
            coordinate [label=below right:$G$] (G) at (intersection-1);
        \draw (G) -- (C);
        \draw [-latex] (H) -- ($(H)!1.18!($(C)!.5!(G)$)$);
        %  Draw arc segments 
        \draw [red]
        let 
            \p1=($ (H) - (C) $), 
            \n2={veclen(\x1, \y1)}
        in 
            (G) arc (180:110:\n2)
            (G) arc (180:185:\n2);

        %  Find other points 
        \path [name path=o2]
        let
            \p2=($ (G) - (C) $),
            \n2={veclen(\x2,\y2)}
        in 
            (C) circle (\n2);
        \path [name intersections={of=o2 and o}]
            coordinate [label=above left:$E$] (E) at (intersection-1);

        \path [name path=o3]
        let
            \p2=($ (G) - (C) $),
            \n2={veclen(\x2,\y2)}
        in 
            (E) circle (\n2);
        \path [name intersections={of=o3 and o}]
            coordinate [] (F) at (intersection-2);

        \path [name path=o4]
        let
            \p2=($ (G) - (C) $),
            \n2={veclen(\x2,\y2)}
        in 
            (F) circle (\n2);
        \path [name intersections={of=o4 and o}]
            coordinate [] (J) at (intersection-2);

        \path [name path=o5]
        let
            \p2=($ (G) - (C) $),
            \n2={veclen(\x2,\y2)}
        in 
            (J) circle (\n2);
        \path [name intersections={of=o5 and o}]
            coordinate [] (K) at (intersection-1);

        %  Draw a regular pentagon 
        \draw [thick] (C) -- (E) -- (F) -- (J) -- (K) -- cycle;
    \end{tikzpicture}
\end{document}

The following points need to be paid attention to :

  1. Two arc segment ( Complete by marking the circle ) The point of intersection needs to pay attention to whether it is the first or the second point of intersection ;
  2. When drawing an arc, you should pay attention to the initial angle , And fine adjustment of arc parameters ;
  3. Give an appropriate alias , To prevent confusion caused by too many parts at the end of the painting .
原网站

版权声明
本文为[zorchp]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202220540410879.html