Re: creating a graphic in a text cell
- To: mathgroup at smc.vnet.net
- Subject: [mg128180] Re: creating a graphic in a text cell
- From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
- Date: Fri, 21 Sep 2012 04:15:05 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
I'm teaching a statics course that naturally requires a lot of depictions of ropes, springs, pulleys, etc. To produce a graphic box I use Ctrl-1 and use the tool palette. This works, a bit painfully, but recently I ran into a need to depict angles with short arcs. I couldn't find a way of doing that that the graphic box would accept. Is there a way to specify an arc, and if so, how? I'm running Mathematica 8.0.4.0 under Mac OS X.6.8. Thanks. - Dushan Mitrovich Hi, Dushan, There is a primitive Circle[] in which you can make a circular arc. Just check Menu/Help/Circle. You may build it iby its evaluation in your notebook, and then you can draw down your sketch around the already existing arc. I also make a lot of drawings illustrating technical texts done in Mathematica. These drawings are not exactly as yours (i.e. to teach something), but they are rather comparable. Since already long time I refused of using the Drawings palette. Instead I do it programmatically using graphics primitives. The reason is that in the same drawing I often combine some elements obtained by one of plotting operations (like say, Plot[]) with other elements that previously I have produced with the palette. Typically as soon as I end up with drawing, I realized that have missed something in the plot, and need to make it once more. That means that I need to make also the whole palette-based drawing once again. After having started drawing with primitives I simply need to re-evaluate the whole code. As the example I just sketched below a simple static problem. You will find there the element entitled arc with the construct you asked about in your post about. Evaluate the code below. (* These are definitions of all elements of the sketch *) base = Graphics[{LightBlue, EdgeForm[{Thin, Black}], Polygon[{{0, 0}, {2, 0}, {2, 2*Tan[\[Pi]/8]}}]}]; brick1 = Graphics[{LightRed, EdgeForm[{Thin, Black}], Translate[ Rotate[Polygon[{{0, 0}, {0.5, 0}, {0.5, 0.25}, {0., 0.25}, {0, 0}}], 0.392], {0.693, 0.417}]}]; arr1 = Graphics[{Red, Thick, Arrow[{{0.944, 0.514}, {0.944 - 0.4 Sin[\[Pi]/8], 0.514 + 0.4 Cos[\[Pi]/8]}}]}]; arr2 = Graphics[{Blue, Thick, Arrow[{{0.944 + 0.044, 0.514 - 0.086}, {0.944 + 0.044 - 0.5 Cos[\[Pi]/8], 0.514 - 0.5 Sin[\[Pi]/8] - 0.086}}]}]; arr3 = Graphics[{Brown, Thick, Arrow[{{0.944, 0.514}, {0.944, 0.1}}]}]; txtN = Graphics[ Text[Style["N", Italic, 18, Red, Bold], {0.874, 0.902}]]; txtmg = Graphics[ Text[Style["mg", Italic, 18, Brown, Bold], {1.062, 0.148}]]; txtkN = Graphics[ Text[Style["F=kN", Italic, 18, Blue, Bold], {0.342 + 0.125, 0.46 - 0.11}]]; arc = Graphics[Circle[{0, 0}, 0.5, {0, \[Pi]/8}]]; txt3 = Graphics[Text[Style["\[Alpha]", 18], {0.546, 0.12}]]; line1 = Graphics[{Thick, Line[{{1.172, 0.632}, {1.172 + 0.806*Cos[\[Pi]/8], 0.632 + 0.806*Sin[\[Pi]/8]}}]}]; disk = Graphics[{LightBlue, EdgeForm[{Thin, Black}], Disk[{2, 2*Tan[\[Pi]/8] + 0.1}, 0.1]}]; line2 = Graphics[{Thick, Line[{{2.1 - 0.015, 2*Tan[\[Pi]/8] + 0.04}, {2.1 - 0.015, Tan[\[Pi]/8] + 0.04}}]}]; brick2 = Graphics[{LightRed, EdgeForm[{Thin, Black}], Polygon[{{2.01, 0.4542}, {2.01 + 0.15, 0.4542}, {2.01 + 0.15, 0.3}, {2.01, 0.3}, {2.01, 0.4542}}]}]; arr4 = Graphics[{Green, Thick, Arrow[{{1.172, 0.632}, {1.172 + 0.3*Cos[\[Pi]/8], 0.632 + 0.3*Sin[\[Pi]/8]}}]}]; arr5 = Graphics[{Green, Thick, Arrow[{{2.1 - 0.015, Tan[\[Pi]/8] + 0.04}, {2.1 - 0.015, Tan[\[Pi]/8] + 0.3}}]}]; arr6 = Graphics[{Black, Thick, Arrow[{{2.1 - 0.015, Tan[\[Pi]/8] - 0.04}, {2.1 - 0.015, Tan[\[Pi]/8] - 0.04 - 0.3}}]}]; txtT1 = Graphics[ Text[Style["T", 18, Italic, Bold, Green], {1.395, 0.83}]]; txtT2 = Graphics[ Text[Style["T", 18, Italic, Bold, Green], {2.172, 0.605}]]; txtMg = Graphics[ Text[Style["Mg", 18, Italic, Bold, Black], {2.206, 0.13}]]; (* here the elements are unified making the sketch *) Show[{base, brick1, arr1, arr2, arr3, txtN, txtmg, txtkN, arc, txt3, line1, disk, line2, brick2, arr4, arr5, arr6, txtT1, txtT2, txtMg}] One can also easily parameterize it and make a movie out of a static drawing. Drawing with primitives goes a bit slower than that with the palette, but still astonishingly fast. It took me about 10 minutes to draw this. There is a simple trick to accelerate the process. Just ask me, if you would find it interesting to learn about it. Have fun, Alexei Alexei BOULBITCH, Dr., habil. IEE S.A. ZAE Weiergewan, 11, rue Edmond Reuter, L-5326 Contern, LUXEMBOURG Office phone : +352-2454-2566 Office fax: +352-2454-3566 mobile phone: +49 151 52 40 66 44 e-mail: alexei.boulbitch at iee.lu
- Follow-Ups:
- Re: creating a graphic in a text cell
- From: James Stein <mathgroup@stein.org>
- Re: creating a graphic in a text cell
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: creating a graphic in a text cell