## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Some PGF/TikZ 3D drawings

Information and discussion about graphics, figures & tables in LaTeX documents.
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

### Some PGF/TikZ 3D drawings

Some drawings inspired by the thread at comp.text.tex about how to convert some hand drawn pictures into programmatic 3D sketches. The sketches present stereographic and cylindrical map projections and they pose some interesting challenges for doing them with a 2D drawing package like PGF/TikZ.

The main idea is to draw in selected 3D planes and then project onto the canvas coordinate system with an appriopriate transformation. Some highlights:
• parametrization of drawings
• usage of pgf math engine for calculation of projection transformations and
transitions points from visible (solid lines) to invisible (dashed lines) on
meridians and latitude circles
• definition of 3D plane transformation with expanded styles so that they are robust
against redefinition of macros used in their construction
• usage of named coordinates (nodes) for definition of characteristic points in
local coordinate systems so that they are accessible outside of their plane of
definition
• calculation of intersections points with TikZ intersection coordinate system
• usage of 'to' path operation instead of 'arc' for marking angles to allow for
easy positioning of text labels on the curve
• 3D lighting effects with shading

Enjoy!

Cheers,

Tomek

EDIT: uploaded an updated version that fixes some incompatibilities with the upcoming PGF version

EDIT 2: By courtesy of Kjell those examples are now also a part of his gallery.

Stereographic projection
globe-1.png (70.4 KiB) Viewed 22952 times

Cylindrical projection
globe-2.png (60.76 KiB) Viewed 22947 times
Attachments
globe.tex
LaTeX source code
Last edited by T3. on Fri Aug 08, 2008 5:36 pm, edited 3 times in total.

Tags:

Stefan Kottwitz
Posts: 9602
Joined: Mon Mar 10, 2008 9:44 pm
Hi Tomek,

that's great work! I hope it will appear among the examples of Kjells gallery.
I compiled it and noticed only a Overfull hbox warning, perhaps that could be fixed just to perfect it.

Stefan

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
Thanks a bunch for this great contribution. There seems to be some kind of flame war in this topic on comp.text.tex - pgf/TikZ vs PSTricks. The first thought that came to me was that these drawings could be done with Sketch. I made that tool successfully running under Linux and Windows and already used it for less complex 3D drawings with pgf/TikZ. I hope there once will be a real 3D engine for this package.

Best regards
Thorsten¹
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm
Stefan_K wrote:that's great work! I hope it will appear among the examples of Kjells gallery.
Thanks. And I have already sent it to Kjell. Now, I am competing for a case of beer with some other pstricks submissions

Stefan_K wrote:I compiled it and noticed only a Overfull hbox warning, perhaps that could be fixed just to perfect it.
I don't know what's causing the warning. Perhaps one of the pictures is too large. Anyway, I've already spent way too much time on those drawings (but I've also learned a lot, so it was worth it).

About shadings: there is also a transparent shading used for one of the pictures but it's commented out in the source because it displayed only in Adobe Reader. There is some cool stuff you can do with TikZ.

BTW, is there a limit on the number of attachments? There are two more pictures in the source but I couldn't attach more then three files.

Cheers

Tomek

T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm
localghost wrote:Thanks a bunch for this contribution. There seems to be some kind of flame war in this topic on comp.text.tex - pgf/TikZ vs PSTricks.
That is quite polite exchange of opinions compared to some other threads I've seen on c.t.t. About PGF/TikZ vs. PSTricks - both packages are pretty powerful and have a similar set of features, so it largely comes down to a personal preference. PGF/TikZ is somewhat cleaner, IMO, have a native support for PDF and offers slightly better integration with TeX. So, that would be my recommendation to newcomers. PSTricks package, OTOH, packs more computing power since it can rely on PostScript engine for calculations and there are 3D extensions available for it.

localghost wrote:The first thought that came to me was that these drawings could be done with Sketch. I made that tool successfully running under Linux and Windows and already used it for less complex 3D drawings with pgf/TikZ. I hope there once will be a real 3D engine for this package.
I've looked at Sketch but I just didn't feel like learning yet another tool. It does look quite impressive but currently lacks 3D curves and 2nd degree solids, so it wouldn't be so useful for the above task. It supports only polygons, AFAIK, but has one neat feature that is lacking in tikz - the ability to define parts of the drawing for later usage and manipulation. Something like that would be a really nice addition to tikz. And I too hope for better 3D support in tikz.

Cheers,

Tomek

propell
Posts: 44
Joined: Fri May 30, 2008 11:16 am
Impressive work Tomek! Looking forward to add them to the gallery.

localghost wrote: PSTricks package, OTOH, packs more computing power since it can rely on PostScript engine for calculations ...

This will probably change when LuaTeX is released...

T3 wrote:I've looked at Sketch but I just didn't feel like learning yet another tool. It does look quite impressive but currently lacks 3D curves and 2nd degree solids, so it wouldn't be so useful for the above task. It supports only polygons, AFAIK, but has one neat feature that is lacking in tikz - the ability to define parts of the drawing for later usage and manipulation. Something like that would be a really nice addition to tikz. And I too hope for better 3D support in tikz.

Sketch is indeed a nice tool. I wrote an introduction to Sketch for tikz users some time ago. The lack of curves is a limitation though. The Asymptote graphic language has very good 3D support and is worth checking out. Unfortunately it lacks some of the tight integration with LaTeX that TikZ has.

If you don't want to learn the Sketch language you can "cheat" and use my Blender to Sketch exporter . I have not used it much myself, but some users have created really stunning illustrations with it.

- Kjell Magne

T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm
propell wrote:Impressive work Tomek! Looking forward to add them to the gallery.
Thanks for all the positive feedback I've received so far¹. I think I should show some modesty (and honesty) here and say that a part of this appreciation (a large part) should be directed to PGF/TikZ developers for all the fine work they have done on this package. I think, that the high quality results that are achieved almost effortlessly with TikZ, can be attributed to a large extent to well thought out defaults and attention to details. Even powerful and expensive commercial packages often require much more sweat and tears from the user simply because they come with mediocre default behaviour.

propell wrote:
localghost wrote: PSTricks package, OTOH, packs more computing power since it can rely on PostScript engine for calculations ...

This will probably change when LuaTeX is released...
Yes, LuaTeX just can't get released soon enough, it seems. It will hopefully resolve a ton of other problems that are crippling TeX for a long time already.

Cheers,

Tomek

¹ I wasn't sure if I should show off like that in this forum in the first place.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
T3. wrote:...
¹ I wasn't sure if I should show off like that in this forum in the first place.

Hi Tomek,

as far as I am concerned, you can show off as much as you like with beautiful contributions like those. Impressive!
1,1,2,3,5,8,13,21,34,55,89,144,233,...

startrucky
Posts: 11
Joined: Mon Aug 18, 2014 2:02 pm
Hi there,
I am actually using this in a modified way which is working fine inwrite latex.
If though transfered to a latex document on my pc the latitude and longtitude circles dissappear and nor error is shown.
Has anybody ever encounter this kind of problem?
Kind regards
sty


The code is changed to the remaining problem of now disordered nodes
Last edited by startrucky on Mon Aug 18, 2014 2:47 pm, edited 3 times in total.

Johannes_B
Site Moderator
Posts: 4186
Joined: Thu Nov 01, 2012 4:08 pm
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.