以下 PSTrick 代码生成的图表所需的 TikZ 代码

以下 PSTrick 代码生成的图表所需的 TikZ 代码

我想要一个 TiKZ 代码来生成以下图表,该图表使用以下 PSTrick 代码绘制,绘制两个同心花瓣图,排列成一个圆圈,一个有 8 个花瓣,外层有 16 个花瓣。(这是在各个网站中发现的 Sri yantra(或 Sri chakra)绘图的一部分,例如: https://codegolf.stackexchange.com/questions/42410/draw-sri-yantra

以下是 PSTrick 代码

\SpecialCoor
\qdisk(0,0){5pt}
\multido{\rAngleA=-11.25+22.50,\rAngleB=11.25+22.50}{16}{%
  \pscustom[fillcolor=blue,fillstyle=solid]{%
    \psarc(0,0){6.5}{\rAngleA}{\rAngleB}
    \psbezier%
      (! 6.5 \rAngleB\space cos mul 6.5 \rAngleB\space sin mul)%
      (! /a \rAngleB\space 7.75 sub def 8 a cos mul 8 a sin mul)%
      (! /a \rAngleB\space 10.25 sub def 7 a cos mul 7 a sin mul)%
      (! /a \rAngleB\space 11.25 sub def 8 a cos mul 8 a sin mul)
    \psbezier%
      (! /a \rAngleA\space 11.25 add def 8 a cos mul 8 a sin mul)
      (! /a \rAngleA\space 10.25 add def 7 a cos mul 7 a sin mul)%
      (! /a \rAngleA\space 7.75 add def 8 a cos mul 8 a sin mul)%
      (! 6.5 \rAngleA\space cos mul 6.5 \rAngleA\space sin mul)%
  }
}

\multido{\rAngleA=-22.5+45.0,\rAngleB=22.5+45.0}{8}{%
  \pscustom[fillcolor=red,fillstyle=solid]{%
    \psarc(0,0){5.5}{\rAngleA}{\rAngleB}
    \psbezier%
      (! 5.5 \rAngleB\space cos mul 5.5 \rAngleB\space sin mul)%
      (! /a \rAngleB\space 6.75 sub def 7 a cos mul 7 a sin mul)%
      (! /a \rAngleB\space 12.5 sub def 5 a cos mul 5 a sin mul)%
      (! /a \rAngleB\space 22.5 sub def 6.5 a cos mul 6.5 a sin mul)
    \psbezier%
      (! /a \rAngleA\space 22.5 add def 6.5 a cos mul 6.5 a sin mul)
      (! /a \rAngleA\space 12.5 add def 5 a cos mul 5 a sin mul)%
      (! /a \rAngleA\space 6.75 add def 7 a cos mul 7 a sin mul)%
      (! 5.5 \rAngleA\space cos mul 5.5 \rAngleA\space sin mul)%
  }
}

答案1

对上述代码进行快速转换可能会得到如下结果:

\documentclass[border=10pt, tikz]{standalone}

\begin{document}
\begin{tikzpicture}
\fill (0,0) circle[radius=5pt];
\foreach \i in {0,...,16} {
    \pgfmathsetmacro{\rAngleA}{-11.25+(22.50*\i)}
    \pgfmathsetmacro{\rAngleB}{11.25+(22.50*\i)}
    \path[draw, fill=blue] 
        (\rAngleA:6.5) arc[radius=6.5, start angle=\rAngleA, end angle=\rAngleB] --
        ({6.5*cos(\rAngleB)},{6.5*sin(\rAngleB)}) .. controls 
        ({8*cos(\rAngleB-7.75)},{8*sin(\rAngleB-7.75)}) and 
        ({7*cos(\rAngleB-10.25)},{7*sin(\rAngleB-10.25)}) ..
        ({8*cos(\rAngleB-11.25)},{8*sin(\rAngleB-11.25)}) --
        ({8*cos(\rAngleA+11.25)},{8*sin(\rAngleA+11.25)}) .. controls 
        ({7*cos(\rAngleA+10.25)},{7*sin(\rAngleA+10.25)}) and 
        ({8*cos(\rAngleA+7.75)},{8*sin(\rAngleA+7.75)}) ..
        ({6.5*cos(\rAngleA)},{6.5*sin(\rAngleA)}) -- cycle;
    \path[draw] 
        (0,0) -- ({6.5*cos(\rAngleA)},{6.5*sin(\rAngleA)})
        (0,0) -- ({8*cos(\rAngleB-11.25)},{8*sin(\rAngleB-11.25)});
}
\foreach \i in {0,...,8} {
    \pgfmathsetmacro{\rAngleA}{-22.5+(45.0*\i)}
    \pgfmathsetmacro{\rAngleB}{22.5+(45.0*\i)}
    \path[draw, fill=red] 
        (\rAngleA:5.5) arc[radius=5.5, start angle=\rAngleA, end angle=\rAngleB] --
        ({5.5*cos(\rAngleB)},{5.5*sin(\rAngleB)}) .. controls
        ({7*cos(\rAngleB-6.75)},{7*sin(\rAngleB-6.75)}) and
        ({5*cos(\rAngleB-12.5)},{5*sin(\rAngleB-12.5)}) ..
        ({6.5*cos(\rAngleB-22.5)},{6.5*sin(\rAngleB-22.5)}) --
        ({6.5*cos(\rAngleA+22.5)},{6.5*sin(\rAngleA+22.5)}) .. controls
        ({5*cos(\rAngleA+12.5)},{5*sin(\rAngleA+12.5)}) and
        ({7*cos(\rAngleA+6.75)},{7*sin(\rAngleA+6.75)}) ..
        ({5.5*cos(\rAngleA)},{5.5*sin(\rAngleA)}) -- cycle;
    \path[draw] 
        (0,0) -- ({5.5*cos(\rAngleA)},{5.5*sin(\rAngleA)})
        (0,0) -- ({6.5*cos(\rAngleB-22.5)},{6.5*sin(\rAngleB-22.5)});
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容