From - Thu Dec  6 12:33:31 2001
Return-Path: <laurent@math.toronto.edu>
Received: from coxeter.math.toronto.edu (coxeter.math.toronto.edu
    [128.100.68.3]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id
    fB6BXMh03510 for <metafont@ens.fr>; Thu, 6 Dec 2001 12:33:22 +0100 (CET)
Received: (from laurent@localhost) by coxeter.math.toronto.edu
    (8.11.0/8.11.0/UTMath 1.0) id fB6BX4K62846; Thu, 6 Dec 2001 06:33:04 -0500
Date: Thu, 6 Dec 2001 06:33:04 -0500
From: Larry Siebenmann <laurent@math.toronto.edu>
Message-Id: <200112061133.fB6BX4K62846@coxeter.math.toronto.edu>
To: B.Jackowski@GUST.ORG.PL, laurent@math.toronto.edu,
    luecking@comp.uark.edu, metafont@ens.fr, tjk@ams.org
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 512
Precedence: list
Subject: [metafont] Quadratic bezier areas




 **  Area formula for quadratic bezier spline curves ** 


Hi all,


Back in the spring of 2000 I discussed with Jacko and Dan
Leucking the area entrapped by *cubic* bezier curves in the plane.  

We arrived at various formulae -- some for thinking, some
for cooking.  One that seems easy to remember is as follows. A
planar bezier curve B(t), 0<=t<=1, with control points
B(0)=a,b,c,d=B(1) entraps the same area as the rational
combination of piecewise linear paths from a to d:

(***)
   .1 (a--d)  +  .3 (a--b--d)  +  .3 (a--c--d)  +  .3 (a--b--c--d)

Notice that the coefficient sum is 1; so I called this a "wooly
polygon".  This provides a formula for the area of any closed path
gotten by chaining together several bezier cubic spline curves.
Indeed it is the weighted sum

               .1 A1 + .3 A2 + .3 A3 + .3 A4

of the areas of four polygons gotten by replacing each bezier by
a linear approximation in the four ways indicated. The area of 
any polygon is easily calculated in terms of vector products.
(Dan indicated tricks to make vector product calculations
particularly efficient.)

I asked then whether any explicit area formula for
bezier curves  in terms of control points is known/published.

There is no definitive answer, but one quotation from
a research article I found on the web mentions area of cubic 
beziers as being difficult to calculate:

http://nr.stic.gov.tw/ejournal/ProceedingA/v24n5/373-381.pdf

Quadratic B-spline for Curve Fitting
WU-CHIH HU * AND HSIN-TENG SHEU **

Proc. Natl. Sci. Counc. ROC(A)
Vol. 24, No. 5, 2000. pp. 373-381
(Short Communication)

<< Further, it is not easy to calculate the curve length, the
enclosed area of a closed curve or the intersection points
of two cubic B-splines as is necessary in most CAD/CAM
applications. For the quadratic B-spline function, such
computation is much simpler. Further, since a quadratic
B-spline curve is closer to its control polygon than a cubic
one, it is somewhat easier to manipulate the curve using
its control polygon. Hence, the quadratic B-spline function
is considered in this paper. >>

Here is the direct analog for quadratic splines of the above area
formula (***). Let B(t), 0<=t<=1, with control points
B(0)=a,b,c=B(1) be a quadratic bezier spline curve.
The rational combination

   (**)          (1/3) (a--c)  +  (2/3) (a--b--c)


is a "wooly piecewise linear path" that entraps the same area as
the curve B(t).

What is more, there is an exceptionally easy proof of (**) as
follows. 

The case when a,b,c are collinear is trivial, so suppose
they are not. Then we can and do normalize a,b,c by an affine
linear transformation sending a --> (-1,1);  b --> (0,-1 );  c -->
(1,1).  The transformed curve is still quadratic bezier and
control points are the assigned images of a,b,c. The
transformed curve is the standard parabola y=x^2 (check this by
chasing definitions).  

For the normalized a,b,c, (**) amounts to the assertion that (2/3)
of the area (=2) of the triangle abc lies inside the parabola. The
simplest integral formula \int x^2 = (1/3) x^3 easily 
proves this.  (See approximate figure.)


          a = (-1,0)                            c = (1,0)
          o--------------------o--------------------o
          \                    |                    /
           \                   |                   /|
            \                  |                  / |
              \                |                /   |
                \              |              /     |
                  \            |            /       |
                    \          |          /    ........Area = (1/3)
                       \       |       /            |
                          \    |    /               |
          ---------------------o----------------------
                               |(0,0)
                               |
                               |
                               |
                               |
                               |
                               |
                               |
                               |
                               |
          ---------------------o----------------------
                              b=(0,-1)


By transforming back one deduces (**) for the originally given
bezier.

---------------

Exercise:  The same normalization method proves two more
basic facts:

(i) Every quadratic bezier curve describes a segment of a
parabola.

(ii) If a,b,c are the control points for a quadratic bezier curve
from a to c, then the axis of the containing parabola is the
oriented line from b through the midpoint of the segment a--c.

---------------

Does (**) make area calculations for font characters of True Type
fonts much easier than our area calculations for Adobe Type 1 fonts
(which use cubics)?  This remains a moot point -- inasmuch as  True
Type fonts use many more bezier curves (incidentally, has anyone
noticed the proportions, say as measured by a well-done native
Times font of each format??).
 
Cheers

Laurent S.


From - Thu Dec  6 15:34:08 2001
Return-Path: <laurent@math.toronto.edu>
Received: from coxeter.math.toronto.edu (coxeter.math.toronto.edu
    [128.100.68.3]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id
    fB6EXth34689 for <metafont@ens.fr>; Thu, 6 Dec 2001 15:33:57 +0100 (CET)
Received: (from laurent@localhost) by coxeter.math.toronto.edu
    (8.11.0/8.11.0/UTMath 1.0) id fB6EXoB58494; Thu, 6 Dec 2001 09:33:50 -0500
Date: Thu, 6 Dec 2001 09:33:50 -0500
From: Larry Siebenmann <laurent@math.toronto.edu>
Message-Id: <200112061433.fB6EXoB58494@coxeter.math.toronto.edu>
To: B.Jackowski@GUST.ORG.PL, laurent@math.toronto.edu,
    luecking@comp.uark.edu, metafont@ens.fr, tjk@ams.org
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 513
Precedence: list
Subject: [metafont]

# Area of quadratic bezier


Correction:

In exercise (ii) of what I just posted, please change

 "axis of the containing parabola"
  ==> 
 "axis direction of the containing parabola"

A definition of "axis direction" that behaves naturally 
under affine linear transformations is:- the unique direction
in the plane in which points on the parabola are seen to 
vanish as they go to infinity.

Exercise (iii) Give a further algorithm to find the (parallel!) line
that is the parabola axis you met in school.

LS


From - Tue Dec 11 11:01:28 2001
Return-Path: <di97mej@student.bth.se>
Received: from mothers.student.bth.se (mothers.student.bth.se
    [194.47.133.17]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id
    fBBA1Eh31389 for <metafont@ens.fr>; Tue, 11 Dec 2001 11:01:18 +0100 (CET)
Received: from MarcusEjnarsson.student.bth.se (itslaptop1.its.hk-r.se
    [194.47.136.151]) by mothers.student.bth.se (8.10.2+Sun/8.10.2) with ESMTP
    id fBBA1DQ19148 for <metafont@ens.fr>; Tue, 11 Dec 2001 11:01:13 +0100
    (MET)
Message-Id: <5.1.0.14.2.20011211105619.03859a10@mail.student.bth.se>
X-Sender: di97mej@mail.student.bth.se
X-Mailer: QUALCOMM Windows Eudora Version 5.1
Date: Tue, 11 Dec 2001 11:03:32 +0100
To: metafont@ens.fr
From: Marcus Ejnarsson <di97mej@student.bth.se>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 514
Precedence: list
Subject: [metafont] MetaPost - vbox/hbox - Centering?

Hello

I have a question about MetaPost and how to center text in vbox/hbox.

In my .mp-file I write like this to create a box contatining some text. 
Anyone who know how I can get the text centered   in the box?

boxit.c(btex \vbox{\hbox{Voice} \hbox{Activation} \hbox{Detection}} etex);

I also wounder if someone know if there is a easy way to get boxes of the 
same height and width (still centered text)

Thankful for any help ....

/Marcus Ejnarsson
MSc Student at Blekinge Institute of Technology


From - Tue Dec 11 11:27:13 2001
Return-Path: <ignasi@ipc4.uib.es>
Received: from lluna.uib.es (lluna.uib.es [130.206.33.10]) by nef.ens.fr
    (8.10.1/1.01.28121999) with ESMTP id fBBAQ9h38034 for <metafont@ens.fr>;
    Tue, 11 Dec 2001 11:27:01 +0100 (CET)
Received: from ipc4.uib.es (pcignasi.uib.es [130.206.134.178]) by
    lluna.uib.es (8.10.0/8.10.0) with ESMTP id fBBAFoX13855 for
    <metafont@ens.fr>; Tue, 11 Dec 2001 11:15:50 +0100 (MET)
Message-Id: <3C15DEEC.5BE96924@ipc4.uib.es>
Date: Tue, 11 Dec 2001 11:24:44 +0100
From: Ignasi =?iso-8859-1?Q?Furi=F3?= Caldentey <ignasi@ipc4.uib.es>
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en,pdf
Mime-Version: 1.0
To: metafont@ens.fr
Subject: Re: [metafont] MetaPost - vbox/hbox - Centering?
References: <5.1.0.14.2.20011211105619.03859a10@mail.student.bth.se>
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 515
Precedence: list


Marcus Ejnarsson wrote:
> 
> Hello
> 
> I have a question about MetaPost and how to center text in vbox/hbox.
> 
> In my .mp-file I write like this to create a box contatining some text.
> Anyone who know how I can get the text centered   in the box?
> 
> boxit.c(btex \vbox{\hbox{Voice} \hbox{Activation} \hbox{Detection}} etex);
> 
> I also wounder if someone know if there is a easy way to get boxes of the
> same height and width (still centered text)
> 

I've been using this:

verbatimtex
\documentclass{article}
\newcommand{\stk}[1]{\parbox[c][2cm][c]{3cm}{\centerline{\begin{tabular}{c}#1\end{tabular}}}}
\newcommand{\stkb}[1]{\parbox[c][4.5cm][c]{3cm}{\centerline{\begin{tabular}{c}#1\end{tabular}}}}
\begin{document}
etex

...
  
boxit.c(btex \stk{Line 1\\Line2} etex, (x,y));


If anybody knows a better solution, I also would like to know it.

	Ignasi
-- 
-------------------------------------------------------
Ignasi Furió Caldentey             ignasi@ipc4.uib.es
Dpt. Matemątiques i informątica    http://dmi.uib.es
Universitat de les Illes Balears   http://www.uib.es
Fax: +34 971 173003  Tel.: +34 971 173196
-------------------------------------------------------


From - Tue Dec 11 12:41:27 2001
Return-Path: <pragma@wxs.nl>
Received: from smtpzilla3.xs4all.nl (smtpzilla3.xs4all.nl
    [194.109.127.139]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id
    fBBBfEh51477 for <metafont@ens.fr>; Tue, 11 Dec 2001 12:41:14 +0100 (CET)
Received: from server-1.pragma-ade.nl (s340-isdn1251.dial.xs4all.nl
    [194.109.184.227]) by smtpzilla3.xs4all.nl (8.12.0/8.12.0) with ESMTP id
    fBBBfDNe006897; Tue, 11 Dec 2001 12:41:13 +0100 (CET)
Received: from laptop-2.wxs.nl (laptop-1.pragma-ade.nl [200.1.1.26]) by
    server-1.pragma-ade.nl (8.11.6/8.11.6) with ESMTP id fBBBIOa19119;
    Tue, 11 Dec 2001 12:18:24 +0100
Message-Id: <5.1.0.14.1.20011211121348.03181d38@server-1>
X-Sender: hagen@server-1
X-Mailer: QUALCOMM Windows Eudora Version 5.1
Date: Tue, 11 Dec 2001 12:17:32 +0100
To: Marcus Ejnarsson <di97mej@student.bth.se>
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: [metafont] MetaPost - vbox/hbox - Centering?
Cc: metafont@ens.fr
In-Reply-To: <5.1.0.14.2.20011211105619.03859a10@mail.student.bth.se>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 516
Precedence: list

At 11:03 AM 12/11/2001 +0100, Marcus Ejnarsson wrote:
>Hello
>
>I have a question about MetaPost and how to center text in vbox/hbox.
>
>In my .mp-file I write like this to create a box contatining some text. 
>Anyone who know how I can get the text centered   in the box?
>
>boxit.c(btex \vbox{\hbox{Voice} \hbox{Activation} \hbox{Detection}} etex);
>
>I also wounder if someone know if there is a easy way to get boxes of the 
>same height and width (still centered text)
>
>Thankful for any help ....

To get a proper alignment you need to make sure that 'lines' have the same 
height and depth which is accomplished by using struts.

In principle you should be able to use the high level macros that the 
package that you use provides. When including the dvi result from 
btex/etec, text and rules are passed to mp, so you can let tex place the 
rules, but in most cases the results are worse than using mp to do that.

In context, the principle can be demonstrated as follows:

\setupcolors[state=start]

\starttext

\startMPpage

picture p, q ;

p := image(boxit.c (btex \framed[frame=off]{Voice}     etex)) ;
q := image(boxit.c (btex \framed[frame=off]{Detection} etex)) ;

draw p withcolor transparent (1,.5,blue) ;
draw q withcolor transparent (1,.5,red) ;

\stopMPpage

\stoptext

[there are more efficient ways].

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


From - Sat Dec 15 21:15:03 2001
Return-Path: <laurent@math.toronto.edu>
Received: from coxeter.math.toronto.edu (coxeter.math.toronto.edu
    [128.100.68.3]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id
    fBFKEth71751 for <metafont@ens.fr>; Sat, 15 Dec 2001 21:14:55 +0100 (CET)
Received: (from laurent@localhost) by coxeter.math.toronto.edu
    (8.11.0/8.11.0/UTMath 1.0) id fBFKEsq84898 for metafont@ens.fr;
    Sat, 15 Dec 2001 15:14:54 -0500
Date: Sat, 15 Dec 2001 15:14:54 -0500
From: Larry Siebenmann <laurent@math.toronto.edu>
Message-Id: <200112152014.fBFKEsq84898@coxeter.math.toronto.edu>
To: metafont@ens.fr
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 517
Precedence: list
Subject: [metafont] quadratic bezier curves in metafont



 ** quadratic bezier curves in metafont **

Hi all,

My excursion last week into quadratic bezier
curves may seem to some of you of interest only to
TrueType font buffs. Not so!

Let me assure you that metafont can draw an
arbitrary quadratic bezier curve. This is well known
to experts, but the proof I'll give may not be the
most common one.

The salient fact is that the restriction
(*) below on the cubic bezier curve F(t), 0<=t<=1, with
control points F(0)=a,b,c,d=F(1) in the plane R^2 is necessary
and sufficient that the curve be quadratic bezier,
or equivalently a (possibly degenerate) parabola.

             (*)      d - a = 3 b - c


         a  o ------------------------------------- o  d
             \                                    /
               \                                 /
                 \                              /
                   \                           /
                     \                        /
                       \                     /
                         \                  /
                        b  o ------------- o  c
                             \            /
                               \         /
                                 \      /
                                   \   /
                                     o   
                                       e       
                               

Furthermore, the quadratic bezier has control points
a,e,d where e is the intersection point of the lines
ab and dc. (What is more, the quadratic and cubic
parametrizations are identical; so the cubic is
degenerate.)

To prove this I like to consider the coefficient of
t^3 in the expansion in powers of t for

 F(t) = s^3*a + 3s^2*t*b + 3s*t^2*c + t^3*d, where s=(1-t)

This coefficient of t^3 is:

    C =  - a  +  3 b  +  -3 c   +   d

and its vanishing is the condition (*)!  Now the
vanishing is equally the condition that F(t) be
quadratic or less, ie a (possibly degenerate) parabola.
But for a parabolic arc a to d with tangent lines ab
and dc the quadratic control points are well known to
be a,e,d. (The degenerate case where a,b,c,d are
colinear needs a bit of extra discussion. Exercise!)
QED.

     At this point you can see how to trivially
convert any TrueType font outline to a Type1 font
outline:- just regard the quadratic bezier segments
as special cubic bezier segments by the above recipe.

Cheers

Laurent S.


PS. There is also a *lossy* conversion Type1 to
TrueType. Does anyone know the details??


From - Sat Dec 15 21:17:24 2001
Return-Path: <laurent@math.toronto.edu>
Received: from coxeter.math.toronto.edu (coxeter.math.toronto.edu
    [128.100.68.3]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id
    fBFKHFh71999 for <metafont@ens.fr>; Sat, 15 Dec 2001 21:17:15 +0100 (CET)
Received: (from laurent@localhost) by coxeter.math.toronto.edu
    (8.11.0/8.11.0/UTMath 1.0) id fBFKHE3138962 for metafont@ens.fr;
    Sat, 15 Dec 2001 15:17:14 -0500
Date: Sat, 15 Dec 2001 15:17:14 -0500
From: Larry Siebenmann <laurent@math.toronto.edu>
Message-Id: <200112152017.fBFKHE3138962@coxeter.math.toronto.edu>
To: metafont@ens.fr
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 518
Precedence: list
Subject: [metafont] cubic (but non-quadratic) bezier curves



 ** cubic (but non-quadratic) bezier curves **

Hi all,

     Recall the "cubic axis" direction

    C =  - a  +  3 b  +  -3 c   +   d

of the bezier cubic curve

 F(t) = s^3*a + 3s^2*t*b + 3s*t^2*c + t^3*d, where s=(1-t)

with control points a,b,c,d. It is just the coefficient of
t^3.

     I like this "cubic axis" direction C because it gives
quick insight into the global behavior of F(t) for t \in
R.  Since bezier curve is a notion that behaves naturally 
under affine linear transformations of R^2, we demand 
the same for properties and constructions. (Euclidian 
notions like angle are banned.)

Assuming the vector C is nonzero, F(t) is definitely not
quadratic, and the curve F(t) goes to infinity in
direction C as t --> \infty.  Likewise it goes to infinity
in direction -C as t --> -\infty.

We need to view the lines in R^2 parallel to C as being 
the points of an affine line L_C  such that one has a natural 
affine linear projection map 

                     p : R^2 --> L_C

One can informally identify L_C with any line transversal to
direction C and p then sends all points on a line parallel to
C to its intersection with L_C. The one problem is that there
is no natural choice of this L_C; but since any two choices
are naturally related by projection parallel to C, the problem
is academic ... we can accept *all* choices.

     One can distinguish three mutually exclusive global
behaviors of F(t) with respect to direction C.

   -- (non-degenerate) The composition

              p o F :  R -->  R

is nondegenerate quadratic in t.  Then the closed convex
hull of the complete curve F(t), t \in R, is a closed half
plane with F(t) tangent at a single point to the bounding
line (parallel to C).

   -- (singly-degenerate) The composition  p o F  is
linear nondegenerate. Equivalently, the four control point
images under p o F, say a',b',c',d', are in linear
progression on L_C. Then the convex hull of the complete
curve F(t), t \in R, is the whole plane. Further, F(t) is
the graph of a cubic function on any line L_C transverse
to the axis C. So F(t) has an unique inflection point I.
Choose I as origin. Choose the tangent line to F(t) at I
as x-axis (it is a privileged choice of L_C). Choose the
line through I in direction C as y-axis. This naturally
re-coordinatizes the plane so that F(t) is (t,t^3) after
rescaling the axes.

   -- (doubly-degenerate) The composition p o F is
constant. Equivalently, the four control points map under
p o F to one point in L_C. Then the complete curve F(t), t
\in R, is confined to one line parallel to C.
   
     It is the first (non-degenerate) case that is of
most geometric interest since one always finds a pair of
inflection points, or else one double point, or else
(exceptionally) a cusp. No time to explain this further
trichotomy today!

Cheers

Laurent S.


From - Tue Dec 18 12:34:29 2001
Return-Path: <laurent@math.toronto.edu>
Received: from coxeter.math.toronto.edu (coxeter.math.toronto.edu
    [128.100.68.3]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id
    fBIBYHh78207 for <metafont@ens.fr>; Tue, 18 Dec 2001 12:34:18 +0100 (CET)
Received: (from laurent@localhost) by coxeter.math.toronto.edu
    (8.11.0/8.11.0/UTMath 1.0) id fBIBYGL65068 for metafont@ens.fr;
    Tue, 18 Dec 2001 06:34:16 -0500
Date: Tue, 18 Dec 2001 06:34:16 -0500
From: Larry Siebenmann <laurent@math.toronto.edu>
Message-Id: <200112181134.fBIBYGL65068@coxeter.math.toronto.edu>
To: metafont@ens.fr
X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan
X-Loop: metafont@nef.ens.fr
X-Sequence: 519
Precedence: list
Subject: [metafont] # quadratic bezier curves in metafont



 # Correction to: "quadratic bezier curves in metafont" #

Hi all

In my recent note "quadratic bezier curves in metafont" 
the equation (*) for degeneration of a cubic
bezier to a quadratic bezier should have been

             (*)      d - a = 3 (c - b)

Happily, the figure was for the correct equation (*), and
the proof too!

Please tell me if there were other slipups!


Laurent S.


