Banner

Donate

You find LaTeX Community useful? Please donate! Learn why!

Amount:

Partner Sites

goLaTeX
TeXblog
TeXnicCenter

Who is online

In total there are 10 users online :: 1 registered, 0 hidden and 9 guests (based on users active over the past 5 minutes)
Most users ever online was 108 on Tue Jun 08, 2010 3:33 pm

Users browsing this forum: Yahoo [Bot] and 9 guests

Some PGF/TikZ 3D drawings

Information and discussion about specific document classes and how to create your own document classes.

Some PGF/TikZ 3D drawings

Postby T3. on Thu Aug 07, 2008 2:33 pm

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.

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

globe-2.png
Cylindrical projection
globe-2.png (60.76 KiB) Viewed 5526 times
Attachments
globe.tex
LaTeX source code
(9.69 KiB) Downloaded 807 times
Last edited by T3. on Fri Aug 08, 2008 4:36 pm, edited 3 times in total.
User avatar
T3.
 
Posts: 199
Joined: Fri Mar 14, 2008 11:58 am

Re: Some PGF/TikZ 3D drawings

Postby Stefan_K on Thu Aug 07, 2008 3:08 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.
Btw. the Adobe Reader displayed it very well, the evince reader could not display the shading properly, just for info.

Stefan
LaTeX Community Moderator
TeXblog.net
Stefan_K
Site Moderator
 
Posts: 2687
Joined: Mon Mar 10, 2008 8:44 pm
Location: Hamburg, Germany

Re: Some PGF/TikZ 3D drawings

Postby localghost on Thu Aug 07, 2008 3:29 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¹
¹ I'm sorry. My responses are limited. You must ask the right questions.
² Systems: openSUSE 11.3, TeX Live 2009, TeXworks 0.3 | Windows XP (SP3), MiKTeX 2.8, TeXworks 0.3
³ Learning TeX.
User avatar
localghost
Site Moderator
 
Posts: 4769
Joined: Fri Feb 02, 2007 11:06 am
Location: Braunschweig, Germany

Re: Some PGF/TikZ 3D drawings

Postby T3. on Thu Aug 07, 2008 3:31 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.
Btw. the Adobe Reader displayed it very well, the evince reader could not display the shading properly, just for info.
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
User avatar
T3.
 
Posts: 199
Joined: Fri Mar 14, 2008 11:58 am

Re: Some PGF/TikZ 3D drawings

Postby T3. on Thu Aug 07, 2008 4:04 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
User avatar
T3.
 
Posts: 199
Joined: Fri Mar 14, 2008 11:58 am

Re: Some PGF/TikZ 3D drawings

Postby propell on Fri Aug 08, 2008 10:38 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
propell
 
Posts: 44
Joined: Fri May 30, 2008 10:16 am

Re: Some PGF/TikZ 3D drawings

Postby T3. on Fri Aug 08, 2008 4:44 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.
User avatar
T3.
 
Posts: 199
Joined: Fri Mar 14, 2008 11:58 am

Re: Some PGF/TikZ 3D drawings

Postby gmedina on Sun Aug 10, 2008 3:29 am

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,...
User avatar
gmedina
 
Posts: 2056
Joined: Wed Jul 11, 2007 10:45 pm
Location: Colombia


Return to Document Classes

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group