luigi scarso | 1 Dec 2010 11:46
Picon

Re: Problem with generating EPS from MetaFont source

On Wed, Dec 1, 2010 at 11:41 AM, Michael Ummels
<michael.ummels <at> rwth-aachen.de> wrote:
> Sorry, when stripping the test file, I removed some dimensions. If you want
> to compile test.mf using MetaFont, replace the line
> define_whole_pixels(equal_spread, arrow_horiz_len,
> arrow_vert_len, arrow_diag_len, arrow_spread, line_thickness,
> rule_thickness, side_bearing);
> by
> define_whole_pixels(equal_spread, arrow_diag_len, arrow_spread,
> line_thickness, rule_thickness, side_bearing);
> Then, if you run "mf '\mode:=localfont; input test'", you will see that it
> compiles just fine.
> Michael
It's ok now, thank you.
--

-- 
luigi

--
http://tug.org/metapost/
Michael Ummels | 1 Dec 2010 11:41
Picon
Picon
Favicon
Gravatar

Re: Problem with generating EPS from MetaFont source

Sorry, when stripping the test file, I removed some dimensions. If you want to compile test.mf using MetaFont, replace the line


define_whole_pixels(equal_spread, arrow_horiz_len, arrow_vert_len, arrow_diag_len, arrow_spread, line_thickness, rule_thickness, side_bearing);

by

define_whole_pixels(equal_spread, arrow_diag_len, arrow_spread, line_thickness, rule_thickness, side_bearing);

Then, if you run "mf '\mode:=localfont; input test'", you will see that it compiles just fine.

Michael

On Wed, Dec 1, 2010 at 10:07, luigi scarso <luigi.scarso <at> gmail.com> wrote:
Not an answer, but a question (a bit off-topic..): how can you process
you test.mf with METAFONT ?
I've tried
# ./mf '&plain \mode:=localfont; mag=100.375; input test'

This is METAFONT, Version 2.718281 (Web2C 7.5.7)
(test.mf
>> 277.77776arrow_horiz_len#+0.5
! Not implemented: floor(unknown numeric).
<to be read again>
                  endgroup
<to be read again>
                  ;
<for(arrow_horiz_len)> ...hround((SUFFIX0)#*hppp);
                                                  ENDFOR
l.13 ...e_thickness, rule_thickness, side_bearing)

--
luigi

--
http://tug.org/metapost/
Yasir Malik | 2 Dec 2010 15:15
Favicon

Problems with passing parameters to macros

Hi,

I'm seeing strange behavior when I pass parameters to a macro.  Consider 
the following code fragment:

File macros.mp:
def someMacro(expr v, a, b, x, y, z) =
begingroup

show "inside func";
show v, a, b;
show "";

...

show "before exiting";
show v, a, b;
show "";

endgroup
enddef;

Another file:

input macros.mp

pair a, b, ap;

...

show "before calling";
show a, b, ap;
show "";
someMacro(a, b, ap, x, y, z);

show "after calling";
show a, b, ap;

Here's the output:

>> "before calling"
>> (-22.32306,38.6648)
>> (-128.55247,0)
>> (-37.20473,64.44066)
>> ""
>> "inside func"
>> (-22.32306,38.6648)
>> (-128.55247,0)
>> (-37.20473,64.44066)
>> ""
>> "before exiting"
>> (-22.32306,38.6648)
>> (-128.55247,0)
>> (-37.20473,64.44066)
>> ""
>> "after calling"
>> (-22.32306,38.6648)
>> (-128.55247,0)
>> (-128.55247,0) [33] )

As you can see, the value of ap is the same as b after coming out of the 
macro.  I'm not sure whether showing the entire code is relevent (there is 
a lot of code and all the parameters in the macro have the value of what I 
passed).  I can try to reproduce this issue with less code, but has anyone 
seen this problem before?

Thanks,
Yasir
--
http://tug.org/metapost/

Yasir Malik | 2 Dec 2010 22:22
Favicon

Re: Problems with passing parameters to macros

I found the problem:

> File macros.mp:
> def someMacro(expr v, a, b, x, y, z) =
> begingroup
>
> show "inside func";
> show v, a, b;
> show "";
>
> ...
>
> show "before exiting";
> show v, a, b;
> show "";
>
> endgroup
> enddef;
>
>
>
> Another file:
>
> input macros.mp
>
>
> pair a, b, ap;
>
> ...
>
> show "before calling";
> show a, b, ap;
> show "";
> someMacro(a, b, ap, x, y, z);
>
> show "after calling";
> show a, b, ap;
>
In macro someMacro, I was declaring "pair ap" but not saving it first.  I 
was then assigning ap to another value that turned out to be the same as 
b.  ap in someMacro then conflicted with ap in the main file.  I guess 
this happens because Metapost expands the macro from whereever you called 
it from, even though the macro is defined in a different file.

I'm simplifying what happened, but this was difficult to trace because ap 
was declared in a macro that was many macros up in the stack of the 
top-level macro I was calling from the main file (macro calls within 
macro calls...).

Thanks,
Yasir
--
http://tug.org/metapost/

Dan Luecking | 4 Dec 2010 00:02
Picon
Favicon

Re: Problem with generating EPS from MetaFont source


[Forgot to copy the list]

Michael Ummels <michael.ummels <at> rwth-aachen.de> wrote:

 >
 > I am trying to use MetaPost to generate EPS files for each
 > character in a
 > MetaFont as described in Appendix B of the MetaPost manual.
 > However, some
 > strokes do not come out correctly or are missing at all in the
 > resulting EPS
 > files. I would be glad if somebody could tell me what is going wrong.
 >
 > To replicate my results, run "mpost '&mfplain \mode:=localfont;
 > mag=100.375;input test'" on the file test.mf, which is given below.
 > In the resulting EPS
 > files test.2 and test.3, strokes are missing/incorrect, whereas
 > test.0 and
 > test.1 are fine.
 >
 > Interestingly, the problem does not occur when using pencircle
 > instead of
 > pensquare.

Metapost has longstanding bugs in the handling of polygonal pens.
It tries to calculate the path of the outermost corner, which can switch
from one corner to another along a curve. Unfortunately, this is a rather
unstable mathematical problem and metapost frequently gets it wrong.
Sometimes an infinitessimal rotation of the pen causes it to come out
right.

You would be advised to calculate these paths yourself and  fill the
resulting outline.

I believe Taco may know more about these issues.

Taco: I have wondered a lot about metapost's problems with polygonal
pens. If someone could point out the code that handles it (and perhaps
a description of the algorithm), I would like to take a whack at figuring
out at least where and/or why it goes wrong.

Dan

Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html 

--
http://tug.org/metapost/

luigi scarso | 4 Dec 2010 02:12
Picon

Re: Problem with generating EPS from MetaFont source

On Sat, Dec 4, 2010 at 12:02 AM, Dan Luecking <luecking <at> uark.edu> wrote:
>
> [Forgot to copy the list]
>
> Michael Ummels <michael.ummels <at> rwth-aachen.de> wrote:
>
>>
>> I am trying to use MetaPost to generate EPS files for each
>> character in a
>> MetaFont as described in Appendix B of the MetaPost manual.
>> However, some
>> strokes do not come out correctly or are missing at all in the
>> resulting EPS
>> files. I would be glad if somebody could tell me what is going wrong.
>>
>> To replicate my results, run "mpost '&mfplain \mode:=localfont;
>> mag=100.375;input test'" on the file test.mf, which is given below.
>> In the resulting EPS
>> files test.2 and test.3, strokes are missing/incorrect, whereas
>> test.0 and
>> test.1 are fine.
>>
>> Interestingly, the problem does not occur when using pencircle
>> instead of
>> pensquare.
>
> Metapost has longstanding bugs in the handling of polygonal pens.
> It tries to calculate the path of the outermost corner, which can switch
> from one corner to another along a curve. Unfortunately, this is a rather
> unstable mathematical problem and metapost frequently gets it wrong.
> Sometimes an infinitessimal rotation of the pen causes it to come out
> right.
>
> You would be advised to calculate these paths yourself and  fill the
> resulting outline.
>
> I believe Taco may know more about these issues.
>
> Taco: I have wondered a lot about metapost's problems with polygonal
> pens. If someone could point out the code that handles it (and perhaps
> a description of the algorithm), I would like to take a whack at figuring
> out at least where and/or why it goes wrong.
The example doesn't compile with
MetaPost, version 1.503 (kpathsea version 6.0.0)
Log says
reloading the plain base, version 0.99: preliminaries,
 basic constants and mathematical macros,
 macros for converting units,
 macros and tables for various modes of operation,
 macros for drawing and filling,
 macros for proof labels and rules,
 macros for character and font administration,
and a few last-minute items.)
! Attempt to close the bottom level file!.
l.584 numeric mode,mag;
                            % but leave mode and mag undefined

It's ok with
This is MetaPost, version 1.211 (TeX Live 2010) (kpathsea version 6.0.0)

--

-- 
luigi

--
http://tug.org/metapost/
Taco Hoekwater | 4 Dec 2010 09:48
Gravatar

Re: Problem with generating EPS from MetaFont source

On 12/04/2010 02:12 AM, luigi scarso wrote:
> The example doesn't compile with
> MetaPost, version 1.503 (kpathsea version 6.0.0)
> Log says

> ! Attempt to close the bottom level file!.

This is easily fixable: when you use mpost 1.503, you also need to use
the mfplain.mp that comes from mpost 1.503's distribution (or add 'dump'
at the end of the file you have on disk already).

For me, it runs past this point (but then it segfaults at finish,
which is a different, totally unrelated bug).

I'll add tracker items for each of these three problems; the one
with the polygonal pen is the hard one to fix. Dan, I'll get back
to you on the algorithm later.

Best wishes,
Taco
--
http://tug.org/metapost/

luigi scarso | 4 Dec 2010 13:28
Picon

Re: Problem with generating EPS from MetaFont source

On Sat, Dec 4, 2010 at 9:48 AM, Taco Hoekwater <taco <at> elvenkind.com> wrote:
> On 12/04/2010 02:12 AM, luigi scarso wrote:
>>
>> The example doesn't compile with
>> MetaPost, version 1.503 (kpathsea version 6.0.0)
>> Log says
>
>> ! Attempt to close the bottom level file!.
>
> This is easily fixable: when you use mpost 1.503, you also need to use
> the mfplain.mp that comes from mpost 1.503's distribution (or add 'dump'
> at the end of the file you have on disk already).
yes, sorry for the noise. Still lots to learn.

> For me, it runs past this point (but then it segfaults at finish,
> which is a different, totally unrelated bug).
true
--

-- 
luigi
--
http://tug.org/metapost/

Boguslaw Jackowski | 4 Dec 2010 15:17
Picon
Favicon

Re: Problem with generating EPS from MetaFont source


Hi,

DL> Metapost has longstanding bugs in the handling of polygonal pens. It
DL> tries to calculate the path of the outermost corner, which can switch
DL> from one corner to another along a curve. Unfortunately, this is a 
DL> rather unstable mathematical problem and metapost frequently gets it 
DL> wrong. Sometimes an infinitessimal rotation of the pen causes it to 
DL> come out right.

... and vice versa. :)

It's true that the problem of calculating the envelope of the polygonal
pen is mathematically unstable (it is not an exception in the realm of
discrete geometry), but this does not explain the bugs -- the 
representation of the path (pen's envelope) may change unstably but 
not its visual appearance. Or I am mistaken?

Cheers -- Jacko

Ps. Some theoretical details about polygonal ("Metafont-oriented") pens 
can be found in: John D. Hobby, Rasterizing Curves of Constant Width, JACM 
36(2), 1989.

--

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Bogus\l{}aw Jackowski: B_Jackowski <at> GUST.ORG.PL
----------------------------------------------------------------
  Hofstadter's Law: It always takes longer than you expect, even
                    when you take into account Hofstadter's Law.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

--
http://tug.org/metapost/

Stefan Witzel | 3 Dec 2010 18:01
Picon
Picon

increase numerical tolerance

Hi,

I'm drawing a picture where I want to cut ellipses inscribed into a circle before and after they meet the
circle. Mostly this works but some ellipses are not cut presumably because metapost thinks that they do
not intersect. Is there any way to increase the numerical tolerance for two paths to intersect? Since I
know for sure that the paths intersect, I could then write an operator that increases the tolerance until
the paths finally intersect. Thanks in advance!

Best regards,
Stefan Witzel
--

-- 
GRATIS! Movie-FLAT mit über 300 Videos. 
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
--
http://tug.org/metapost/

Gmane