3

enter image description here

Here is what I am trying to draw that in LaTeX.

percusse
  • 157,807
Mohammad
  • 966
  • What do you have? Why do you want to draw it in LaTeX? It is not great for 3D. – cfr Feb 23 '16 at 04:00
  • @ Arun Debray, what does mean? I found that you wanted to bring attentions to my questions. Correct? – Mohammad Feb 23 '16 at 04:00
  • The question was edited because you'd tagged it incorrectly. Now it has a relevant tag. Or, at least, a potentially relevant one. diagrams or something package-neutral might be better as you didn't specify any package. But tikz-pgf is closer than word ;). – cfr Feb 23 '16 at 04:02
  • As I was saying ... ;). – cfr Feb 23 '16 at 04:03
  • @percusse @ cfr any suggestion how to draw this then? – Mohammad Feb 23 '16 at 04:13
  • TikZ doesn't understand z ordering. So you need to draw the bottom 3 sides then the cube then the top 3 sides to give this effect. – percusse Feb 23 '16 at 04:17
  • @percusse can you give me a worked example? It helps me much to start that – Mohammad Feb 23 '16 at 04:19
  • I can't really because I am on the phone. I'm sure people will chime in in a few hours. You can also try to at least try to draw the bottom 3 sides and show what you achieved. – percusse Feb 23 '16 at 04:30
  • 5
    Some people take exception to questions of the form "Please draw this for me". You will get more help if you post some code showing what you have tried and give a minimal working example. –  Feb 23 '16 at 06:30

1 Answers1

7

For 3D graphics, Asymptote is probably the best of the LaTeX-friendly graphics programming languages. I am a beginner at Asymptote, but 15 minutes with Charles Staat's tutorial produced this:

enter image description here

And here's the program that produced it.

import three;

size3(100,100,100);
currentprojection = perspective(10,7,4);

surface i  = shift(-1/2,-1/2,-1/2) * unitcube;
path3[] ii = shift(-1/2,-1/2,-1/2) * unitbox;
surface o  = scale3(2) * i;
path3[] oo = scale3(2) * ii;

draw(i, red+opacity(0.5));
draw(o, grey+opacity(0.3));

draw(ii);
draw(oo);

I've no idea if this is good style, and I'm sure there must be a better way to draw the edges of a surface. The tutorial explains how to add labels.

EDIT: There is indeed a better way to draw the edges of a surface; all you have to do is pass a second colour to the draw command.

draw(i, red+opacity(0.5),black);
draw(o, white+opacity(0.3),black);

Then there is no need for the unitbox objects.

Thruston
  • 42,268
  • 1
    An external programme is definitely superior for 3D. Except for maybe pstricks, which I am not sufficiently familiar with to say one way or another. But TikZ really isn't good for 3D.... (Which is to say, you can make stunning stuff but neither easily nor flexibly, although tikz-3dplot is definitely helpful. But it is having to work so hard to fake something which Asymptote seems to handle easily.) Your '15 minutes' comment almost persuades me even I could learn to use it a little ;). – cfr Feb 23 '16 at 12:20
  • @cfr - yes I keep thinking the same thing, but Metapost always lures me back... Charles Staats' work on the Asymptote tutorial is first class (although still incomplete). – Thruston Feb 23 '16 at 12:26
  • I started to learn Metapost but then discovered TikZ.... – cfr Feb 23 '16 at 12:32
  • There's a filldraw command. Can you use that with a surface or only a path? – cfr Feb 23 '16 at 12:34
  • 1
    @cfr, see updated answer - all you need is to pass a second colour - simple, but not very obvious to this novice! – Thruston Feb 23 '16 at 18:24
  • Neat! Too bad I can't upvote again ;). – cfr Feb 23 '16 at 20:24
  • I think none of above answers are good. The quality of drawing is too weak for even a report. – Mohammad Feb 24 '16 at 01:44
  • I think the jaggies you see are because I've rendered the PDF produced by Asymptote at a fairly low resolution for pasting here. Asymptote does "proper" three dimensional rendering so that the lines get smaller in the background etc. You can adjust it to make any desired quality you need, but you need to read the documentation carefully to get it right. Why don;t you do some experiments to see what you can get? – Thruston Feb 24 '16 at 15:27
  • @ Thruston , sure. I will do make a try on that. – Mohammad Feb 25 '16 at 00:02
  • I tried to use above example using texstudio. I called the package. Studio compliled the code without errors but it did not draw in pdf file. It was blank. What I am missing here. – Aschoolar Jun 16 '18 at 18:17