Alexander Lazic wrote:
> Oh btw: i have see in the syntax-diagramm sin.
> 
> 1.) is this the sinus function?

 Sure.  (The sine function as used by mathematicians.  If you want the
sine of an angle expressed in degrees, I believe you want sind.)

> 2.) i have try
> 
> ---
> \startreusableMPgraphic{sin}
> 
>   sin (1);
> \stopreusableMPgraphic{sin}

 This {sin} at the end is wrong; it's interpreted as text.

> 
> \reuseMPgraphic{sin}
> ---
> 
> and get:
> 
> Isolated expression.
> 
> Do you know what's going wrong?

 It's the same error as trying to “plot” the MP code

 1;

MetaPost is confused since it has no idea what to do with that number
and tells you so.  Since MP can handle more than just numbers, you get a
slightly more general error message that talks about an “expression”
rather than a “number.”


 What you can do is something like

\starttext

\startusableMPgraphic{sin}
  for x := 0 step 0.6282 until 6.282:
    drawdot(10*x, 10*sin(x)) withpen pencircle scaled 1pt;
  endfor
\stopusableMPgraphic

\useMPgraphic{sin}

\stoptext


Or, you can use the fact that in MetaPost you can build up an expression
within a for loop as follows:


\starttext

\startusableMPgraphic{sin}
  draw (0,0)
  for x := 0 step 0.2 until 6.282: ..(10*x, 10*sin(x)) endfor;
\stopusableMPgraphic

\useMPgraphic{sin}

\stoptext


 I think it really helps with MP programming to understand this type of
loops.


Christopher
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to