# [NTG-context] z0---z1---z2---z3---cycle strange effect

Taco Hoekwater taco at elvenkind.com
Thu Jun 14 11:24:49 CEST 2007

Mojca Miklavec wrote:
> draw z0---z1---z2---z3---cycle withpen pencircle scaled 5pt;
>
> resulting in
>
> newpath
> 14.17323 42.51968 moveto
> 14.17139 42.52553 70.85913 70.86505 70.86613 70.86613 curveto
> 70.88313 70.86877 184.25645 14.18352 184.25194 14.17323 curveto
> 184.2461 14.15994 70.87599 42.51889 70.86613 42.51968 cureveto
> 70.86118 42.52008 14.17513 42.5137 14.17323 42.51968 curveto
> closepath
>
> If you ask me, this looks pretty much like a rendering bug in Mac's

agree

> but on the
> other hand metapost could have generated a shorter & cleaner output as
> well:
>
> newpath
> 14.17323 42.51968 moveto
> 70.86613 70.86613 lineto
> 184.25194 14.17323 lineto
> 70.86613 42.51968 lineto
> 14.17323 42.51968 lineto
> closepath

It would have done that, if the input would have been:

draw z0--z1--z2--z3--cycle withpen pencircle scaled 5pt;

Small differences like this should not be removed automatically, in
my opinion, as they will be visible if the image is to be printed
as a poster (A0 format).

> I suspect that the problem lies in control points of bezier curve
> which are way too close to original points and thus lead to problems
> with numerical precision, but I didn't experiment much deeper, so my
> assumption might be wrong.

Almost certainly, but rounding errors are not an excuse for obviously
incorrect rendering.

Best wishes, Taco