Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I read that TikZ, PSTricks and MetaPost are 2D vector graphics packages while Asymptote is considered 3D. However I also know that you can specify 3D coordinates in say TikZ so that drawing a 3D diagram in TikZ is not merely drawing its projection onto 2D. Given these considerations, what really is meant by 2D or 3D graphics and what is the difference between them?

share|improve this question
add comment

2 Answers

up vote 13 down vote accepted

TikZ is not really a 3D package. It provides a third dimension but in the plane of the other two. You can give drawings some perspective to make it look like they're 3D, but that's really up to the user. I wouldn't call something truly 3D unless I can change the viewing point in one place and have the diagram render from that point of view automatically.

Here's a problem: take four points in three-space and draw the tetrahedron that they define. How would you do that in TikZ? It's easy to connect the four vertices, but depending on the viewer's perspective, some vertices and/or edges are going to be hidden by other ones. So they should be rendered differently or not at all.

How do you determine which parts are hidden? In this example it's probably just a linear algebra problem based on the vertices and the perspective. But if you add something to the diagram you might occlude stuff you've already drawn. So a systematic 3D rendering can't be done until the whole diagram is defined.

There are programs like Sketch 3D which allow you to define the figures, makes the calculations and outputs TikZ code. But it doesn't come built into TikZ.

Edit: Herbert notified me of the pst-solides3d package, which does 3D drawing with any viewport in PSTricks. That means it's possible in TikZ as well, and at the rate of TikZ growth it might be built-in or provided with TikZ someday soon. But it is a pretty complicated undertaking.

share|improve this answer
    
Ah, thanks, now I start to understand. Maybe you could make it even clearer in your answer what 3D graphics really means. (As paper and screens usually are 2D, it always only looks like it's 3D, even if you use a 3D package.) –  Hendrik Vogt Dec 15 '10 at 17:05
    
@Jasper: I tried to elaborate in my edit. –  Matthew Leingang Dec 15 '10 at 19:33
    
@Hendrik: I edited. Hopefully that makes more sense. –  Matthew Leingang Dec 15 '10 at 19:35
add comment

pst-solides3d can handle hidden lines and surfaces.

share|improve this answer
    
I was not aware of that package, Herbert. It's beautiful, and it does meet my on-the-fly definition of 3D graphics package as one where you can change the viewport on the fly. –  Matthew Leingang Dec 16 '10 at 5:30
    
@Matthew: can you use this for animations? And do you have a link to what you did? –  Herbert Dec 24 '10 at 13:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.