ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Christopher Creutzig <christopher@creutzig.de>
Subject: Re: Q: about \externalfile from metafun-p.pdf
Date: Sun, 02 Oct 2005 22:36:37 +0200	[thread overview]
Message-ID: <434044D5.8090109@creutzig.de> (raw)
In-Reply-To: <20051002185852.GB19384@none.at>

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

  reply	other threads:[~2005-10-02 20:36 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-02 17:27 Alexander Lazic
2005-10-02 17:54 ` Christopher Creutzig
2005-10-02 18:58   ` Alexander Lazic
2005-10-02 20:36     ` Christopher Creutzig [this message]
2005-10-03  8:03       ` Alexander Lazic
2005-10-03 17:26         ` Christopher Creutzig
2005-10-04  8:29           ` function plotting (was: Re: Q: about \externalfile from metafun-p.pdf) Alexander Lazic
2005-10-04 16:07             ` function plotting Christopher Creutzig
2005-10-04 19:17               ` Alexander Lazic
2005-10-04 17:48             ` function plotting (was: Re: Q: about \externalfile from metafun-p.pdf) Mojca Miklavec
2005-10-04 19:20               ` Alexander Lazic
2005-10-05  6:17                 ` function plotting David Arnold
2005-10-05  9:02                   ` Alexander Lazic
2005-10-04 22:33               ` Christopher Creutzig
2005-10-05  7:18                 ` Hans Hagen
2005-10-05 13:22                   ` David Arnold
2005-10-05  7:05               ` Hans Hagen
2005-10-05  9:06                 ` Alexander Lazic
2005-10-05 12:08                 ` David Munger
2005-10-05 15:02                 ` Mojca Miklavec
2005-10-06 11:51                   ` Christopher Creutzig
2005-10-04 19:14             ` Peter Münster
2005-10-04 20:25               ` Alexander Lazic
2005-10-05  6:16                 ` Peter Münster
2005-10-05  6:43                   ` luigi.scarso
2005-10-05 21:08                     ` Alexander Lazic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=434044D5.8090109@creutzig.de \
    --to=christopher@creutzig.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).