Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: creating a graphic in a text cell

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128212] Re: Re: creating a graphic in a text cell
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Tue, 25 Sep 2012 04:38:36 -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

>That code produces a very nice figure. But, where do all those numeric coordinates come from?

Dear Murray, dear Community members,

I just have seen your question after I already answered the more voluminous questions of Dushan and several other people. In that answer I give details, and among others answer also this question. I posted it today, and you will see details, if you like.

However, the answer to your precise question is very simple. I guess that it may also be interested to the other community members, therefore, I post it at the MathGroup. Here it is.

When I start drawing, I envelope the whole thing with the Manipulate statement with dummy parameters. As soon as I need to settle a coordinate or angle or few of them, I put them in the parametric form, such that these parameters coincide with those in Manipulate. Then I simply play with the sliders and find the necessary coordinates and enter them into the figure parameters. I specify give the parameters like  this:

Manipulate[

Graphics[Polygon[{{x1,y1},{x2,y2},{x3,y3},{x1,y1}}]],

{x1,0,1},{y1,0,1},{x2,0,1},{y2,0,1},{x3,0,1},{y3,0,1}]

But this is not the fastest way. If I have at least a slightest guess of what would be approximately the positions of the points, a good idea would be to centre around this guess. I do it like the following. Say I know that the two points of the triangle are at {0,0} and {2,0}. Assume that I do not know the third point, but can guess that it is somewhere about {2.5, 1.3}. Its precise position may depend e.g., upon other elements of the drawing. Then I do the following:

Manipulate[
 Graphics[Polygon[{{0, 0}, {2, 0}, {2.5 + x1, 1.3 + y1}}]],
 {x1, -1, 1}, {y1, -1, 1}]

It is simply somewhat faster, than to adjust all the three vertexes. As soon as I have settled the point, say, at x1=0.325, y1=0.2546, I simply copy-paste them into the code and come to these strangely-looking coordinates :

Graphics[Polygon[{{0, 0}, {2, 0}, {2.5 + 0.325, 1.3 + 0.2546}}]]

That is where it comes from.

> I presume this took a lot of experimentation to get things to look just right.

No, with Manipulate it takes few seconds to do.

> Would it not be wonderful if there were a way in Mathematica to draw something with the Drawing Tools (or some similar facility) that would automatically provide the coordinates of where the cursor is placed and then more or less automatically translate what you've drawn into actual Mathematica code such as you show?

I agree. That would be really good.


Regards, 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







  • Prev by Date: sudoku solver
  • Next by Date: Re: NonlinearModelFit and assumptions on fit parameters
  • Previous by thread: Re: RE: creating a graphic in a text cell
  • Next by thread: Washington DC Area Mathematica SIG