2

I was drawing a commutative-diagram when I had the (questionable?) idea of drawing a tetrahedral version of it. I used Asymptote in the hope of getting good-looking thumbnail and a nice embedded 3D model at the same time. This is what I got so far:

On the left side, a planar commutative diagram.  On the right side, a thumbnail of a tetrahedron.

After activating the diagram and rotating around freely, I realized that my 3D model doesn't really look pleasant:

On the left side, the previous planar commutative diagram.  On the right side, an activated embedded 3D model of a tetrahedron.

I would like to make the following improvements:

  1. Arrow start and end positions are automatically calculated like in tikz-cd such that I don't need to use Fill on the labels or use the convexcomb routine.
  2. Allow arrows in the front to cross over the ones in the back, analogous to the tikz-cd option crossing over.
  3. Arrows look good without activating the model.
  4. Arrows look good in 3D with camera rotation.

I don't really know how to do 1 & 2. Moreover, 3 & 4 seem to be contradictory goals. What should my realistic goal be and what improvements should I make? Source:

settings.render = 0;
import solids;
import three;
size(240,120);
defaultpen(basealign);

real side = 1;
triple origin = (0,0,0);
triple voa = (0,0,sqrt(6)/3*side);
triple vob = (sqrt(3)/4*side,-.5*side,0);
triple voc = (sqrt(3)/4*side,.5*side,0);
triple vod = (-sqrt(3)/3*side,0,0);

triple convexcomb(triple a, triple b, real x)
{
  return (1-x) * a + x * b;
}

// A: U
// B: V1x...xVn
// C: W
// D: V

draw(convexcomb(vob,voa,.15)--convexcomb(vob,voa,.85),L=Label("$\varphi$",align=NW)         ,Arrow3(TeXHead2(normal=O)));
draw(convexcomb(vob,voc,.15)--convexcomb(vob,voc,.85),L=Label("$\psi$"   ,align=unit(4*S+W)),Arrow3(TeXHead2(normal=X)));
draw(convexcomb(vob,vod,.15)--convexcomb(vob,vod,.85),L=Label("$\phi$"   ,align=unit(4*N+E)),Arrow3(TeXHead2(normal=O)));
draw(convexcomb(voa,voc,.15)--convexcomb(voa,voc,.85),L=Label("$T_{0}$"  ,align=E)          ,Arrow3(TeXHead2(normal=O)));
draw(convexcomb(voa,vod,.15)--convexcomb(voa,vod,.85),L=Label("$\Pi$"    ,align=unit(E+NE)) ,Arrow3(TeXHead2(normal=O)));
draw(convexcomb(vod,voc,.15)--convexcomb(vod,voc,.85),L=Label("$T$"      ,align=unit(E+SE)) ,Arrow3(TeXHead2(normal=O)));

label(Label("$U$",Fill(white)),voa);
label(Label("$V_{1}\times\cdots\times V_{n}$",Fill(white)),vob);
label(Label("$W$",Fill(white)),voc);
label(Label("$V$",Fill(white)),vod);
  • 1
    For 1. the draw command has a Margin3(number,number) parameter. But it is not automatic with respect to the Label. For an automatic command, a routine should be written. – O.G. Jun 21 '18 at 8:33
  • For 2., in 3D such a crossing over is difficult to implement, it depends on the projection and cannot be interactive. (in 2D it should be possible to have such a crossing over). For the arrows question, the projection of TeXHead2 is not interactive. Try 3D version ? – O.G. Jun 21 '18 at 8:42
  • @O.G. Thanks for the Margin3. I'm thinking about having the cross over only on the thumbnail but not the 3D. Do I have to manage two scripts, if I want the thumbnail to have TeXHead2 arrows and crossover and the 3D to have Arrow3 and no crossover? – Frenzy Li Jun 21 '18 at 8:45
  • 2
    Even though I really love asymptote, I am wondering if you are willing to also consider a TikZ solution here. After all you do not seem to really need a 3D engine, i.e. hide certain elements behind surfaces. – user121799 Jun 21 '18 at 16:03
  • 1
    I guess that this would be very simple to do with tikz-cd. This is "secretly" using a matrix of node, and you could shift nodes into the "z-direction" simply by adding something like |[xshift=-1cm,yshift=-1cm]| to the matrix, ah, sorry, diagram. – user121799 Jun 23 '18 at 1:45
4

Here is a proposal for a pseudo-3D tikz-cd diagram.

\documentclass[border=2pt]{standalone}
\usepackage{amssymb,amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{arrows}

\usepackage{tikz}

\begin{document}
\tikzset{zshift/.style={xshift={-0.3*#1},yshift={-0.9*#1}}}

\begin{tikzcd}[row sep=2cm,column sep=2cm,inner sep=1ex]
& U \arrow{d}{T_0} \arrow{dr}{\Pi} & \\
V_1\times\cdots V_n \arrow{ur}{\varphi} 
\arrow{r}{\phi} \arrow{rr}{\psi}&
|[zshift=-1.5cm]| V \arrow{r}{T}& |[zshift=1cm]|W
\end{tikzcd}

\end{document}

enter image description here

  • This is fantastic. I tweaked the settings to \tikzset{zshift/.style={xshift={0},yshift={-.8*#1}}} to get this. Much appreciated! – Frenzy Li Jun 23 '18 at 2:39
  • 1
    @FrenzyLi Looks great! (Most likely one could tweak the matrix in such a way that one does not have to put in the zshift by hand, but this would be perhaps too much effort and also perhaps more fragile than it should be, so I leave that for now. ;-) – user121799 Jun 23 '18 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.