27.01.2014 Views

Barycentric Coordinates for Arbitrary Polygons in the Plane

Barycentric Coordinates for Arbitrary Polygons in the Plane

Barycentric Coordinates for Arbitrary Polygons in the Plane

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8 K. Hormann<br />

Figure 4: In this example, Ψ is a set of four simple polygons and we show contour<br />

plots of three of our generalized barycentric coord<strong>in</strong>ate functions λ i . They equal 1 at<br />

<strong>the</strong> vertex v i , equal 0 at all o<strong>the</strong>r vertices of Ψ, and are l<strong>in</strong>ear along edges.<br />

Due to <strong>the</strong> Lagrange and l<strong>in</strong>earity properties of <strong>the</strong> coord<strong>in</strong>ates, this function <strong>in</strong>terpolates<br />

f i at v i and is l<strong>in</strong>ear along <strong>the</strong> edges e i of Ψ. An example where <strong>the</strong> f i are colour<br />

values is shown <strong>in</strong> Figure 5.<br />

4 Implementation<br />

For <strong>the</strong> actual computation of <strong>the</strong> <strong>in</strong>terpolation function F we use Equation (11) to<br />

determ<strong>in</strong>e <strong>the</strong> homogeneous coord<strong>in</strong>ates w i (v) and <strong>the</strong>ir sum W (v), but we suggest<br />

a slight modification that avoids <strong>the</strong> computation of <strong>the</strong> angles α i (v) and enables an<br />

efficient handl<strong>in</strong>g of <strong>the</strong> special cases that can occur. If we let s i (v) = v i − v and<br />

denote <strong>the</strong> dot product of s i (v) and s i+1 (v) by D i (v), <strong>the</strong>n we have<br />

tan(α i (v)/2) = 1 − cos(α i(v))<br />

s<strong>in</strong>(α i (v))<br />

= r i(v)r i+1 (v) − D i (v)<br />

,<br />

2A i (v)<br />

and we use this <strong>for</strong>mula as long as A i (v) ≠ 0. O<strong>the</strong>rwise, v lies on <strong>the</strong> l<strong>in</strong>e through v i<br />

and v i+1 and we dist<strong>in</strong>guish three cases. If v = v i or v = v i+1 , <strong>the</strong>n we do not bo<strong>the</strong>r<br />

to compute <strong>the</strong> w i (v) and simply set F (v) = f i or F (v) = f i+1 . Likewise, if v lies on<br />

<strong>the</strong> edge e i , <strong>the</strong>n we use <strong>the</strong> l<strong>in</strong>earity of F along e i to determ<strong>in</strong>e F (v) directly. Note<br />

that we can easily identify this case because it implies D i (v) < 0. F<strong>in</strong>ally, if v is not<br />

on Ψ <strong>the</strong>n we conclude that α i (v) = 0 and <strong>the</strong>re<strong>for</strong>e tan(α i (v)/2) = 0.<br />

The pseudo-code <strong>for</strong> comput<strong>in</strong>g F (v) is given <strong>in</strong> Figure 6. Note that we can also use<br />

this approach to compute each s<strong>in</strong>gle coord<strong>in</strong>ate function λ j by simply sett<strong>in</strong>g f i = δ ij .<br />

INSTITUT FÜR INFORMATIK

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!