From ec77c38ea21989cd3b4068768f94b8e8153c408b Mon Sep 17 00:00:00 2001 From: David Himmelstrup Date: Fri, 6 Dec 2019 17:46:00 +0800 Subject: [PATCH] Update tut text. Former-commit-id: ad9266b099effe06059d4b390ac6d90f8a271477 --- docs/gallery.md | 15 --------------- docs/glue_tut.md | 5 +++-- examples/tut_glue_povray_ortho.hs | 9 +++------ 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/docs/gallery.md b/docs/gallery.md index d618912..fa2a5c8 100644 --- a/docs/gallery.md +++ b/docs/gallery.md @@ -256,18 +256,3 @@ This file is auto-generated by docs/render_all.sh. DO NOT EDIT.


-## tut_glue_povray_ortho - -
- View tut_glue_povray_ortho.hs -

-  {!examples/tut_glue_povray_ortho.hs!}
-  
-
-
- - -


- diff --git a/docs/glue_tut.md b/docs/glue_tut.md index f7aa86e..b509e1f 100644 --- a/docs/glue_tut.md +++ b/docs/glue_tut.md @@ -120,7 +120,7 @@ The resulting SVGs can be manipulated just like any other. The below examples il ## Pillar III: povray -TODO: Draw text and animate shapes, zoom out so it looks like a piece of paper (still animated). +Although incredibly expressive, SVGs are strictly limited to 2D graphics. This limitation can be overcome with a 3D renderer such as povray: povray is a nearly 30 year-old raytracer with a relatively small but solid set of features. Reanimate offers convenient functions for importing povray scenes as well as exporting animations to be used as textures. In the video below, the LaTeX animation is projected upon a plane which is then rotated and translated in 3D space. A key thing to note is that both the 2D and 3D elements are managed entirely through code.
Toggle source code. @@ -134,7 +134,8 @@ TODO: Draw text and animate shapes, zoom out so it looks like a piece of paper ( -TODO: Talk about orthographic projection. Draw circle, fade in rotating sphere. + +The video above uses a perspective camera, ie. objects further away appears to be smaller. This gives the appearance of three dimensions but it also makes it difficult to interlace SVG objects and 3D objects with pixel-perfect precision. For example, aligning a cube and a square requires the exact position of the pinhole camera. All of this can be dramatically simplified with an orthographic projection where 'x' an 'y' coordinates in 3D space always map to the same 'x' and 'y' coordinates on the screen. Shapes lose their perspective but in many cases, especially when illustrating mathematical concepts, drawing "idealized" shapes is perfectly fine. The video below shows an orthographic projection of a sphere. The sphere (3D shape) could be completely eclipsed by a circle (2D shape) of the same radius with pixel-perfection.
Toggle source code. diff --git a/examples/tut_glue_povray_ortho.hs b/examples/tut_glue_povray_ortho.hs index 60c36a1..a84b5e6 100755 --- a/examples/tut_glue_povray_ortho.hs +++ b/examples/tut_glue_povray_ortho.hs @@ -35,17 +35,14 @@ main = reanimate $ parA bg $ sceneAnimation $ do povraySlow [] $ script (svgAsPngFile (texture (t/dur))) (getX real_t) (getY real_t) (getZ real_t) wait 2 - let tDuration = 20 + let tDuration = 10 tweenVar yRot tDuration (\t v -> fromToS v (v+180) $ curveS 2 (t/tDuration)) tweenVar xRot (tDuration/2) (\t v -> fromToS v (v+60) $ curveS 2 (t/(tDuration/2))) fork $ do wait (tDuration/2) tweenVar xRot (tDuration/2) (\t v -> fromToS v (v-60) $ curveS 2 (t/(tDuration/2))) - --tweenVar zRot 9 (\t v -> fromToS v 360 $ curveS 2 (t/9)) wait tDuration wait 2 - --tweenVar zPos 2 (\t v -> fromToS v 0 $ curveS 3 (t/2)) - --wait 2 where bg = animate $ const $ mkBackgroundPixel $ PixelRGBA8 252 252 252 0xFF @@ -67,8 +64,8 @@ camera { orthographic location <0,0,-10> look_at <0,0,0> - up <0,9,0> - right <16,0,0> + up y*9 + right x*16 }