README.do.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. ======= Pysketcher =======
  2. Tool for defining sketches of physics problems in terms of Python code.
  3. ===== Purpose =====
  4. Pysketcher can typically be used to draw figures like
  5. FIGURE: [doc/src/tut/fig-tut/wheel_on_inclined_plane, width=600 frac=0.6]
  6. Such figures can easily be *interactively* made using a lot of drawing programs.
  7. A Pysketcher figure, however, is defined in terms of computer code. This gives
  8. a great advantage: geometric features can be parameterized in term
  9. of variables. Geometric variations are then trivially generated, and
  10. complicated figures can be built as a hierarchy of simpler elements.
  11. Here is a very simple figure that illustrates how geometric features are
  12. parameterized by variables (H, R, L, etc.):
  13. FIGURE: [doc/src/tut/fig-tut/vehicle0_dim, width=600 frac=0.6]
  14. One can then quickly change parameters, below to
  15. `R=0.5; L=5; H=2` and `R=2; L=7; H=1`, and get new figures that would be
  16. tedious to draw manually in an interactive tool.
  17. FIGURE: [doc/src/tut/fig-tut/vehicle_v23, width=800]
  18. Another major feature of Pysketcher is the ability to let the
  19. sketch be dynamic and make an animation of the time evolution.
  20. Here is an example of a very simple vehicle on a bumpy road,
  21. where the solution of a differential equation (upper blue line) is fed
  22. back to the sketch to make a vertical displacement of the spring and
  23. other objects in the vehicle. "View animation": "http://hplgit.github.io/bumpy/doc/src/mov-bumpy/m2_k1_5_b0_2/index.html" (the animation was created by
  24. "this Pysketcher script": "https://github.com/hplgit/bumpy/blob/master/doc/src/fig-bumpy/bumpy_road_fig.py").
  25. FIGURE: [http://hplgit.github.io/bumpy/doc/src/mov-bumpy/m2_k1_5_b0_2/tmp_frame_0030.png, width=600]
  26. ===== Tutorial =====
  27. For an introduction to Pysketcher, see the tutorial in "HTML": "http://hplgit.github.io/pysketcher/doc/pub/pysketcher.html", "Sphinx": "http://hplgit.github.io/pysketcher/doc/pub/html/index.html", or "PDF": "http://hplgit/github.io/pysketcher/doc/pub/pysketcher.pdf" format (or a simplified version of
  28. the tutorial in Chapter 9 in "A Primer on Scientific Programming with Python": "http://www.amazon.com/Scientific-Programming-Computational-Science-Engineering/dp/3642549586/ref=sr_1_2?s=books&ie=UTF8&qid=1407225588&sr=1-2&keywords=langtangen", by H. P. Langtangen, Springer, 2014).
  29. ===== Examples =====
  30. See the `examples` directory for some examples beyond the more basic
  31. ones in the tutorial.
  32. For example, a pendulum and its body diagram,
  33. FIGURE: [examples/pendulum2, width=800 frac=1]
  34. can be created by the program "`examples/pendulum.py`": "https://github.com/hplgit/pysketcher/tree/master/examples/pendulum.py".
  35. ===== Technology =====
  36. Pysketcher applies Matplotlib to make the drawings, but it is quite
  37. easy to replace the backend `MatplotlibDraw.py` by similar code utilizing
  38. TikZ or another plotting package. The Pysketcher software is a thin
  39. layer basically constructing a tree structure of elements in the
  40. sketch. A lot of classes are offered for different type of basic
  41. elements, such as Circle, Rectangle, Text, Text with arrow, Force,
  42. arbitrary curve, etc.
  43. Complicated figures can be created by sticking one
  44. figure into another
  45. (i.e., hierarchical building of figures by sticking one tree
  46. structure into another).
  47. ===== Citation =====
  48. If you use Pysketcher and want to cite it, you can either cite this
  49. web site or the book
  50. that has the original documentation of the tool.
  51. BibTeX format:
  52. !bc
  53. @book{Langtangen_2014,
  54. title = {A Primer on Scientific Programming With {P}ython},
  55. author = {H. P. Langtangen},
  56. year = {2014},
  57. publisher = {Springer},
  58. edition = {Fourth},
  59. }
  60. @misc{Pysketcher,
  61. title = {{P}ysketcher: {D}rawing tool for making sketches},
  62. author = {H. P. Langtangen},
  63. url = {https://github.com/hplgit/pysketcher},
  64. key = {Pysketcher},
  65. note = {\url{https://github.com/hplgit/pysketcher}},
  66. }
  67. !ec
  68. Publish format:
  69. !bc
  70. * books
  71. ** A Primer on Scientific Programming With {P}ython
  72. key: Langtangen_2014
  73. author: H. P. Langtangen
  74. year: 2014
  75. publisher: Springer
  76. status: published
  77. edition: Fourth
  78. entrytype: book
  79. * misc
  80. ** {P}ysketcher: {D}rawing tool for making sketches
  81. key: Pysketcher
  82. author: H. P. Langtangen
  83. url: https://github.com/hplgit/pysketcher
  84. status: published
  85. sortkey: Pysketcher
  86. note: \url{https://github.com/hplgit/pysketcher}
  87. !ec
  88. ===== History =====
  89. Pysketcher was first constructed as a powerful educational example on
  90. object-oriented programming for the book
  91. *A Primer on Scientific Programming With Python*, but the tool quickly
  92. became so useful for the author that it was further developed and
  93. heavily used for creating figures in other documents.