[metapost] Re: new is_clockwise routine

Paul Pichaureau paul.pichaureau at alcandre.net
Sun Nov 27 09:32:24 CET 2005


Le samedi 26 novembre 2005 à 19:51:46, vous écriviez :


GB> In general, to find the clockwiseness of a single Bézier
GB> cubics it suffices to check for the sign of

GB> (P1 - P0) × (P2 - P1)

GB> and

GB> (P2 - P1) × (P3 - P2)

GB> (P0, P1, P2, P3 are the points that define the curve: P0 ..
GB> controls P1 and P2 .. P3)

I've tried to implement an algorithm of this type.

Hélas, it's quite impossible in metapost, due to the limitation of the
magnitude of real number. For example, with the bezier curve

(-50,-50).. controls (50,150) and (150,50) ... (300,300)

metapost have to compute

(100,200) x (100,-100) =  -10 000 - 20 000 < 4 096   BANG !

and

(100,-100) x (150,250) = 25000 + 15 000 > 4 096 re-BANG !

The worst is the result can be really simple (e.g. 0 or -1) but the
metapost refuse even intermediate numbers greater than 4096...


-- 
  Paul Pichaureau                            www.alcandre.net




More information about the metapost mailing list