Drawing diagrams easily
- To: mathgroup at smc.vnet.net
- Subject: [mg48023] Drawing diagrams easily
- From: Goyder Dr HGD <h.g.d.goyder at cranfield.ac.uk>
- Date: Fri, 7 May 2004 04:29:41 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
The starting point for most technical calculations is a diagram. What is the fastest way of getting a diagram into a Mathematica notebook? I offer my solution below and ask for some help. I suggest that the general approach should be to use the point-and-click features together with tinkering with a list of graphics primitives. My approach is to draw a grid and then to click points onto the diagram and round them to the grid as necessary. The rounding to the grid is important because roughly drawn lines become horizontal or vertical, and lines that need to be of equal length can be drawn with ease. I currently add a line, or other primitive, by 1) clicking on the graphic to select it 2) holding down the control key while clicking points onto the graphic 3) copy to the clipboard using control - c 4) paste into a line primitive apply a rounding rule and then evaluate 5) copy and paste the new primitive into the list of graphics primitives and evaluate the modified diagram This is not too difficult but could be speeded up if a set of buttons were available. A typical button would, for example, copy the points that had been clicked onto the selected graphic, round, insert into a line primitive, append the primitive to the list of graphics primitives and redraw the graphic. Even a subset of these actions would be helpful. Has anyone generated a set of buttons and got a good scheme working or can someone help with a button or palette? The example below shows the generation of the grid, a rounding rule, the current state of the list of graphic items. A subsequent cell shows a line into which points have been pasted. This line needs to be evaluated and the output copied and inserted into the graphics list. The next line may now be inserted. Thanks Hugh Goyder x1 = 0; y1 = 0; x2 = 1; y2 = 0.6; xi = 0.01; yi = 0.01; gg = {RGBColor[0, 1, 0], Table[Line[{{x1, y}, {x2, y}}], {y, y1, y2, yi}], Table[Line[{{x, y1}, {x, y2}}], {x, x1, x2, xi}]}; rr = {a_ /; NumberQ[a], b_ /; NumberQ[b]} :> {xi*Round[a/xi], yi*Round[b/yi]}; person = {Line[{{0.32, 0.33}, {0.48, 0.48}}], Circle[{0.51, 0.51}, 0.04], Circle[{0.538, 0.522}, 0.005], Line[{{0.53, 0.5}, {0.54, 0.49}}], Line[{{0.44, 0.44}, {0.52, 0.33}}], Line[{{0.32, 0.33}, {0.4, 0.25}}], Line[{{0.4, 0.25}, {0.37, 0.16}, {0.39, 0.16}}]}; road = {Line[{{0.03, 0.05}, {0.87, 0.05}}]}; bike = {Thickness[0.003], Line[{{0.21, 0.14}, {0.33, 0.26}}], Line[{{0.34, 0.29}, {0.3, 0.29}}], Line[{{0.32, 0.29}, {0.35, 0.16}}], Line[{{0.56, 0.14}, {0.52, 0.31}}], Circle[{0.52, 0.32}, 0.008], Circle[{0.21, 0.14}, 0.09], Circle[{0.56, 0.14}, 0.09], Circle[{0.36, 0.14}, 0.02]}; Show[Graphics[{gg, road, person, bike}], AspectRatio -> Automatic, PlotRange -> All, ImageSize -> 720]; (* Paste new coordinates into this line primative and evaluate to give a line rounded to the grid *) Line[{{0.328758, 0.260854}, {0.529762, 0.26205}}] //. rr -- This message has been scanned for viruses and dangerous content by the Cranfield MailScanner, and is believed to be clean.