如何绘制两个三角形相交于一个公共三角形

如何绘制两个三角形相交于一个公共三角形

我想要绘制tikz下图:

在此处输入图片描述

我想用虚线框画出两个三角形,它们在公共三角形中相交。但是我发现这很难,有人能帮我吗?

这是我的代码:

\begin{tikzcd}
a \arrow[r, "\lambda"] & b \arrow[r, "\mu"] \arrow[d,"\pi"] & c \arrow[r,"\ell"] \arrow[d,"\rho" ]   & s \arrow[d,"\ell^\prime"]                 &                           \\
                  & d \arrow[r,"\sigma" ] \arrow[lu,  squiggly]      & e \arrow[r,"\mu^\prime"] \arrow[d, "\phi"]   & x \arrow[r,"\theta"] \arrow[d,"\rho^\prime" ]               & a[2] \arrow[d]               \\
                  &                             & p \arrow[r,"\sigma^{\prime}"] \arrow[lu, squiggly] & y \arrow[r,"\theta^\prime"] \arrow[d]          & b[2] \arrow[d]    \\
                  &                             &                             & z \arrow[r,"\nu"] \arrow[lu, squiggly] & c[2] \arrow[d,"\ell{[2]}"]      \\
                  &                             &                             &                                     & s[2] \arrow[lu,  squiggly]
\end{tikzcd}

答案1

我不太确定两个三角形相交时是否仍应显示轮廓,图片中显示了两种选择。
这里我选择了后者。

代码

\documentclass[tikz, border=1mm]{standalone}
%\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing, quotes}
\tikzset{
  above'/.style={above=\pgfdecorationsegmentamplitude},
  right'/.style={right=\pgfdecorationsegmentamplitude},
  brace settings/.style={amplitude=4pt},
  brace length/.initial=.75cm,
  pics/brace'/.style={/tikz/rotate=180, brace={#1}},
  pics/brace/.style={
    /tikz/sloped, /tikz/allow upside down,
    code={
      \draw[decorate, decoration={name=brace, /tikz/brace settings}]
      ({-(\pgfkeysvalueof{/tikz/brace length})},3pt)
      -- node[midway,style/.expand once=\tikzpictextoptions]{\tikzpictext}
      ({\pgfkeysvalueof{/tikz/brace length}},3pt);}}}
\begin{document}
\begin{tikzpicture}
\coordinate (tl) at (0,0);
\coordinate (br) at (5,-5);
\coordinate (tr) at (tl-|br);
\coordinate[shift={(-2,-1.5)}] (bl-rect) at (tr);
% or with calc library
% \coordinate(bl-rect) at ($(tr)+(-2,-1.5)$);

% bl-rect|-0,0 is just a point above or below of bl-rect
% bl-rect-|0,0 is just a point left or right of bl-rect
\coordinate (bl-rect-y) at (intersection of bl-rect--bl-rect|-0,0 and tl--br);
\coordinate (bl-rect-x) at (intersection of bl-rect--bl-rect-|0,0 and tl--br);

\filldraw[gray, fill=gray!50] (bl-rect) -- (bl-rect-y) -- (bl-rect-x) -- cycle;

\draw (bl-rect) |- pic[near end,  "$\Delta$"  above'] {brace'} (tl) -- (br)
                |- pic[near start,"$\Delta'$" right'] {brace'} cycle;
\draw[dash pattern=on 4\pgflinewidth off 1.5\pgflinewidth]
  (tr) rectangle ([shift={(3pt,3pt)}]bl-rect);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容