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.

IFI TECHNICAL REPORTS<br />

Institute of Computer Science,<br />

Clausthal University of Technology<br />

IfI-05-05<br />

Clausthal-Zellerfeld 2005


<strong>Barycentric</strong> <strong>Coord<strong>in</strong>ates</strong> <strong>for</strong> <strong>Arbitrary</strong> <strong>Polygons</strong> <strong>in</strong> <strong>the</strong> <strong>Plane</strong><br />

Kai Hormann<br />

Institute of Computer Science, Clausthal University of Technology, Germany<br />

Abstract<br />

<strong>Barycentric</strong> coord<strong>in</strong>ates <strong>for</strong> triangles are commonly used <strong>in</strong> computer graphics,<br />

geometric modell<strong>in</strong>g, and o<strong>the</strong>r computational sciences <strong>for</strong> various purposes. In<br />

this paper, we extend this well-known concept and propose a generalization to sets<br />

of arbitrary polygons <strong>in</strong> <strong>the</strong> plane. Besides many o<strong>the</strong>r important properties, our<br />

coord<strong>in</strong>ate functions are local and smooth and allow an efficient and robust implementation.<br />

These coord<strong>in</strong>ates are particularly useful <strong>for</strong> <strong>in</strong>terpolat<strong>in</strong>g data that<br />

is given at <strong>the</strong> vertices of <strong>the</strong> polygons and we present several examples of <strong>the</strong>ir<br />

application to common problems <strong>in</strong> computer graphics and geometric modell<strong>in</strong>g.<br />

1 Introduction<br />

It follows from Ceva’s Theorem 1 (Ceva, 1678) that <strong>for</strong> any po<strong>in</strong>t v <strong>in</strong>side a planar<br />

triangle [v 1 , v 2 , v 3 ] <strong>the</strong>re exist three masses w 1 , w 2 , and w 3 , such that, if placed at<br />

<strong>the</strong> correspond<strong>in</strong>g vertices of <strong>the</strong> triangle, <strong>the</strong>ir centre of mass (or barycentre 2 ) will<br />

co<strong>in</strong>cide with v, i.e.,<br />

w 1 v 1 + w 2 v 2 + w 3 v 3<br />

w 1 + w 2 + w 3<br />

= v. (1)<br />

Möbius 3 was <strong>the</strong> first to study such mass po<strong>in</strong>ts and he def<strong>in</strong>ed w 1 , w 2 , and w 3 as <strong>the</strong><br />

barycentric coord<strong>in</strong>ates of v (Möbius, 1827). Evidently, <strong>the</strong>se barycentric coord<strong>in</strong>ates<br />

are only unique up to multiplication by a common non-zero scalar and <strong>the</strong>y are usually<br />

normalized to sum to one.<br />

These normalized triangular barycentric coord<strong>in</strong>ates are l<strong>in</strong>ear <strong>in</strong> v and have <strong>the</strong> additional<br />

property that <strong>the</strong> i-th coord<strong>in</strong>ate has value 1 at v i and 0 at <strong>the</strong> o<strong>the</strong>r v j . This<br />

is why <strong>the</strong>y are commonly used to l<strong>in</strong>early <strong>in</strong>terpolate values given at <strong>the</strong> vertices of<br />

a triangle and have applications <strong>in</strong> computer graphics (e.g. Gouraud and Phong shad<strong>in</strong>g,<br />

texture mapp<strong>in</strong>g, ray-triangle-<strong>in</strong>tersection), geometric modell<strong>in</strong>g (e.g. triangular<br />

Bézier patches, spl<strong>in</strong>es over triangulations), and many o<strong>the</strong>r fields (e.g. <strong>the</strong> f<strong>in</strong>ite element<br />

method, terra<strong>in</strong> modell<strong>in</strong>g).<br />

1 Giovanni Ceva, 1647–1734<br />

2 from greek: β ˜αρύς (barys) = heavy, deep, dense<br />

3 August Ferd<strong>in</strong>and Möbius, 1790–1868<br />

1


2 K. Hormann<br />

In many applications it would be useful to have a generalization of barycentric coord<strong>in</strong>ates<br />

to arbitrary n-sided polygons or even sets of polygons <strong>in</strong> <strong>the</strong> plane with vertices<br />

v 1 , . . . , v n . One would <strong>the</strong>n like to have smooth homogeneous barycentric coord<strong>in</strong>ates<br />

w i : IR 2 → IR that generalize Equation (1),<br />

n∑<br />

w i (v)(v i − v) = 0, (2)<br />

i=1<br />

and associated normalized barycentric coord<strong>in</strong>ates,<br />

λ i (v) =<br />

w i (v)<br />

∑ n<br />

j=1 w j(v) , (3)<br />

so that any po<strong>in</strong>t v <strong>in</strong> <strong>the</strong> plane can be written as an aff<strong>in</strong>e comb<strong>in</strong>ation of v 1 , . . . , v n<br />

with weights λ 1 (v), . . . , λ n (v). Fur<strong>the</strong>rmore, <strong>the</strong>se coord<strong>in</strong>ates should satisfy <strong>the</strong> Lagrange<br />

property<br />

{<br />

1 if i = j,<br />

λ i (v j ) = δ ij =<br />

(4)<br />

0 if i ≠ j.<br />

As we will show <strong>in</strong> Section 3 <strong>the</strong>re are many ways of def<strong>in</strong><strong>in</strong>g homogeneous barycentric<br />

coord<strong>in</strong>ates, but <strong>for</strong> most choices <strong>the</strong> normalized coord<strong>in</strong>ates <strong>in</strong> (3) ei<strong>the</strong>r are not<br />

well-def<strong>in</strong>ed everywhere <strong>in</strong> IR 2 , or do not meet <strong>the</strong> constra<strong>in</strong>ts <strong>in</strong> (4). Never<strong>the</strong>less,<br />

we present a particular choice that fulfills all properties. Our generalized barycentric<br />

coord<strong>in</strong>ates have a number of o<strong>the</strong>r important properties and enable a very efficient and<br />

robust implementation as shown <strong>in</strong> Section 4.<br />

The ma<strong>in</strong> application of <strong>the</strong>se coord<strong>in</strong>ates is <strong>in</strong>terpolation and <strong>in</strong> Section 5 we show<br />

several examples from computer graphics and geometric modell<strong>in</strong>g that can be seen as<br />

<strong>in</strong>terpolation problems and hence can be solved with our approach. In particular, we<br />

propose an improved Phong shad<strong>in</strong>g method <strong>for</strong> non-triangular faces, a simple image<br />

warp<strong>in</strong>g technique, and <strong>in</strong>terpolation of data that is specified on planar curves.<br />

2 Related Work<br />

2.1 <strong>Barycentric</strong> <strong>Coord<strong>in</strong>ates</strong><br />

Most of <strong>the</strong> previous work on barycentric coord<strong>in</strong>ates discusses <strong>the</strong> extension to convex<br />

polygons. The first such generalization appears <strong>in</strong> <strong>the</strong> pioneer<strong>in</strong>g work of Wachspress<br />

(1975) who was <strong>in</strong>terested <strong>in</strong> extend<strong>in</strong>g <strong>the</strong> f<strong>in</strong>ite element method. These Wachspress<br />

coord<strong>in</strong>ates are rational polynomials and were later generalized to convex polytopes by<br />

Warren (1996) who also showed that <strong>the</strong>y have m<strong>in</strong>imal degree (Warren, 2003). They<br />

can be computed with simple and local <strong>for</strong>mulas <strong>in</strong> <strong>the</strong> plane (Meyer et al., 2002) as well<br />

as <strong>in</strong> higher dimensions (Warren et al., 2003) and have many o<strong>the</strong>r nice properties like<br />

aff<strong>in</strong>e <strong>in</strong>variance. An extension of Wachspress coord<strong>in</strong>ates to weakly convex polygons<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 3<br />

has been suggested by Malsch and Dasgupta (2004b) but <strong>the</strong>ir construction is iterative<br />

and <strong>the</strong> result<strong>in</strong>g coord<strong>in</strong>ate functions cannot be expressed <strong>in</strong> a local <strong>for</strong>m.<br />

O<strong>the</strong>r generalizations of barycentric coord<strong>in</strong>ates to convex polygons and even to<br />

<strong>the</strong> kernel of a star-shaped polygon were presented <strong>in</strong> <strong>the</strong> context of triangle mesh<br />

parameterization, <strong>for</strong> example <strong>the</strong> discrete harmonic (P<strong>in</strong>kall and Polthier, 1993; Eck<br />

et al., 1995) and <strong>the</strong> mean value coord<strong>in</strong>ates (Floater, 2003). Also <strong>the</strong> natural neighbour<br />

<strong>in</strong>terpolants that were proposed by Sibson (1980, 1981) <strong>for</strong> <strong>the</strong> purpose of scattered<br />

data <strong>in</strong>terpolation provide barycentric coord<strong>in</strong>ates <strong>for</strong> convex polygons, but like <strong>the</strong><br />

coord<strong>in</strong>ates <strong>in</strong> (Far<strong>in</strong>, 1990) <strong>the</strong>y are not more than C 1 -cont<strong>in</strong>uous away from <strong>the</strong> data<br />

po<strong>in</strong>ts. Hiyoshi and Sugihara (2000) have recently extended Sibson’s approach and<br />

presented C k -cont<strong>in</strong>uous coord<strong>in</strong>ates, but <strong>the</strong>ir computation is very costly and <strong>in</strong>volves<br />

numerical <strong>in</strong>tegration.<br />

Except <strong>for</strong> <strong>the</strong> discrete harmonic coord<strong>in</strong>ates, all <strong>the</strong>se coord<strong>in</strong>ates have <strong>in</strong> common<br />

that <strong>the</strong>y are positive over <strong>the</strong> <strong>in</strong>terior of any convex polygon. In fact, this property has<br />

often been used <strong>in</strong> <strong>the</strong> def<strong>in</strong>ition of barycentric coord<strong>in</strong>ates <strong>in</strong>stead of <strong>the</strong> weaker <strong>in</strong>terpolation<br />

condition (4) which is <strong>in</strong> any case a consequence of positivity <strong>in</strong> <strong>the</strong> convex<br />

case, as discussed by Floater et al. (2005). They also proved that <strong>for</strong> a convex polygon<br />

<strong>the</strong> Wachspress and <strong>the</strong> mean value coord<strong>in</strong>ates are <strong>the</strong> only positive coord<strong>in</strong>ates with<br />

uni<strong>for</strong>m scal<strong>in</strong>g <strong>in</strong>variance that can be computed with a local three-po<strong>in</strong>t-<strong>for</strong>mula.<br />

For non-convex polygons a usual approach is to triangulate <strong>the</strong> doma<strong>in</strong> and apply<br />

<strong>the</strong> standard barycentric coord<strong>in</strong>ates on each triangle, but <strong>the</strong> result depends on <strong>the</strong> particular<br />

triangulation chosen and is only C 0 -cont<strong>in</strong>uous over <strong>the</strong> edges of <strong>the</strong> triangles.<br />

To <strong>the</strong> best of our knowledge, <strong>the</strong> recent paper by Malsch and Dasgupta (2004a) is <strong>the</strong><br />

only one that addresses <strong>the</strong> construction of smooth coord<strong>in</strong>ates <strong>for</strong> non-convex polygons.<br />

Their coord<strong>in</strong>ate functions are well-def<strong>in</strong>ed over <strong>the</strong> convex hull of any concave<br />

polygon with possible holes.<br />

Contributions. The barycentric coord<strong>in</strong>ates that we present are more general as<br />

<strong>the</strong>y can be constructed <strong>for</strong> any set of non-<strong>in</strong>tersect<strong>in</strong>g polygons and are well-def<strong>in</strong>ed<br />

everywhere <strong>in</strong> <strong>the</strong> plane. They are smooth (i.e. C ∞ ) except at <strong>the</strong> vertices of <strong>the</strong> polygons<br />

where <strong>the</strong>y are only C 0 and can be computed with a simple and local <strong>for</strong>mula.<br />

These properties make <strong>the</strong>m an ideal tool <strong>for</strong> <strong>the</strong> <strong>in</strong>terpolation of data that is given at<br />

<strong>the</strong> vertices.<br />

2.2 Interpolation<br />

The <strong>in</strong>terpolation of data that is given at <strong>the</strong> vertices of a set of polygons can be seen<br />

as a scattered data <strong>in</strong>terpolation (SDI) problem and many different approaches exist<br />

to solve it, <strong>in</strong>clud<strong>in</strong>g radial basis functions (Beatson et al., 1999; Buhmann, 2000) and<br />

bivariate spl<strong>in</strong>es (Lee et al., 1997; Nürnberger and Zeilfelder, 2000). Such <strong>in</strong>terpolation<br />

problems frequently occur <strong>in</strong> various fields of science and eng<strong>in</strong>eer<strong>in</strong>g (e.g. geology,<br />

reverse eng<strong>in</strong>eer<strong>in</strong>g, numerical simulation) but also <strong>in</strong> computer graphics and geometric<br />

modell<strong>in</strong>g.<br />

Technical Report IfI-05-05


4 K. Hormann<br />

(a)<br />

(b) (c) (d) (e) (f)<br />

Figure 1: We consider convex (a), star-shaped (b), simple (c), and sets of simple polygons<br />

(d), but not polygons with <strong>in</strong>tersect<strong>in</strong>g edges (e) or multiple vertices (f).<br />

One example is image warp<strong>in</strong>g (see Wolberg (1990); Glasbey and Mardia (1998);<br />

Milliron et al. (2002) <strong>for</strong> an overview of <strong>the</strong> state-of-<strong>the</strong>-art) and radial basis functions<br />

(Arad et al., 1994; Ruprecht and Müller, 1995) as well as B-spl<strong>in</strong>es (Lee et al.,<br />

1995, 1997) have been used <strong>in</strong> this context.<br />

Ano<strong>the</strong>r important problem is that of transf<strong>in</strong>ite <strong>in</strong>terpolation where <strong>the</strong> data to be<br />

<strong>in</strong>terpolated is given as functions over a set or network of planar curves. There exist<br />

a number of well-established methods <strong>for</strong> some special cases, like Coons’ or Gordon<br />

surfaces (Far<strong>in</strong>, 2002) <strong>for</strong> triangular- or rectangular-shaped <strong>in</strong>put curves, but very few<br />

are known <strong>for</strong> <strong>the</strong> general case. The standard approach is to ei<strong>the</strong>r sample <strong>the</strong> data and<br />

apply an SDI method or to solve a partial differential equation (PDE) with <strong>the</strong> given data<br />

as boundary conditions (Chai et al., 1998; Kounchev, 2001). But like <strong>the</strong> generalization<br />

of Sibson’s <strong>in</strong>terpolants that was suggested by Gross and Far<strong>in</strong> (1999), this is usually<br />

very costly to compute.<br />

Contributions. Due to <strong>the</strong> Lagrange property of our generalized barycentric coord<strong>in</strong>ates,<br />

<strong>in</strong>terpolation of data that is given at <strong>the</strong> vertices of a set of polygons can be<br />

done directly and efficiently without solv<strong>in</strong>g a l<strong>in</strong>ear system. In <strong>the</strong> context of transf<strong>in</strong>ite<br />

<strong>in</strong>terpolation, <strong>the</strong> locality of our coord<strong>in</strong>ate functions fur<strong>the</strong>r enables a simple and<br />

progressive update of <strong>the</strong> solution if <strong>the</strong> sampl<strong>in</strong>g density is <strong>in</strong>creased. Interest<strong>in</strong>gly,<br />

our <strong>in</strong>terpolat<strong>in</strong>g surfaces are often strik<strong>in</strong>gly similar to <strong>in</strong>terpolat<strong>in</strong>g th<strong>in</strong> plate spl<strong>in</strong>es,<br />

even though our approach requires far less computational ef<strong>for</strong>t.<br />

3 Def<strong>in</strong>ition and Properties<br />

Let Ψ be an arbitrary polygon or a set of arbitrary polygons <strong>in</strong> <strong>the</strong> plane with n ≥ 3<br />

dist<strong>in</strong>ct vertices v 1 , . . . , v n and non-<strong>in</strong>tersect<strong>in</strong>g (open) edges e i = (v i , v i+1 ) =<br />

{(1 − µ)v i + µv i+1 : 0 < µ < 1}; see Figure 1 <strong>for</strong> some examples. If Ψ is a set of<br />

(possibly nested) polygons, we require <strong>the</strong> orientations of <strong>the</strong> polygons to alternate as<br />

shown <strong>in</strong> Figure 14 (a) <strong>in</strong> Appendix B.<br />

We def<strong>in</strong>e <strong>for</strong> any v ∈ IR 2 <strong>the</strong> usual Euclidian distance r i (v) = ‖v i − v‖ to v i and<br />

denote by α i (v) <strong>the</strong> signed angle <strong>in</strong> <strong>the</strong> triangle [v, v i , v i+1 ] at <strong>the</strong> vertex v. Then<br />

A i (v) = r i (v)r i+1 (v) s<strong>in</strong>(α i (v))/2 (5)<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 5<br />

r i+1<br />

v i–1<br />

v<br />

v i+1<br />

α<br />

α i<br />

r i–1 i–1<br />

A i Ψ<br />

v i<br />

A i–1 r i<br />

v<br />

B i<br />

Ψ<br />

C i<br />

v i–1<br />

v i<br />

v i+1<br />

Figure 2: Notation used <strong>for</strong> angles, areas, and distances.<br />

and<br />

B i (v) = r i−1 (v)r i+1 (v) s<strong>in</strong>(α i−1 (v) + α i (v))/2 (6)<br />

are <strong>the</strong> signed areas of <strong>the</strong> triangles [v, v i , v i+1 ] and [v, v i−1 , v i+1 ], respectively 4 ; see<br />

Figure 2. It is well-known (Coxeter, 1969) that<br />

A i (v), −B i (v), A i−1 (v)<br />

are <strong>the</strong> homogeneous barycentric coord<strong>in</strong>ates <strong>for</strong> any v ∈ IR 2 with respect to <strong>the</strong> triangle<br />

△ i = [v i−1 , v i , v i+1 ], <strong>in</strong> o<strong>the</strong>r words,<br />

A i (v)(v i−1 − v) − B i (v)(v i − v) + A i−1 (v)(v i+1 − v) = 0. (7)<br />

Note that every vertex v i of Ψ has a correspond<strong>in</strong>g coord<strong>in</strong>ate <strong>in</strong> each of <strong>the</strong> three<br />

triangles △ i−1 , △ i , and △ i+1 . We can now take <strong>for</strong> every v i a weighted average of<br />

<strong>the</strong>se three coord<strong>in</strong>ates and def<strong>in</strong>e<br />

w i (v) = b i−1 (v)A i−2 (v) − b i (v)B i (v) + b i+1 (v)A i+1 (v), (8)<br />

where <strong>the</strong> weight functions b i : IR 2 → IR can be chosen arbitrarily. Then it follows<br />

immediately from (7) that <strong>the</strong>se functions w i are homogeneous barycentric coord<strong>in</strong>ates<br />

with respect to Ψ, i.e. <strong>the</strong>y satisfy Equation (2).<br />

The critical part now is <strong>the</strong> normalization of <strong>the</strong>se homogeneous coord<strong>in</strong>ates, i.e. to<br />

guarantee that <strong>the</strong> denom<strong>in</strong>ator <strong>in</strong> (3) is non-zero <strong>for</strong> every v ∈ IR 2 .<br />

For convex polygons this is relatively easy to achieve. Indeed, it can be derived<br />

from (8) that<br />

n∑<br />

n∑<br />

W (v) = w i (v) = b i (v)C i , (9)<br />

i=1<br />

where C i = A i−1 (v) + A i (v) − B i (v) is <strong>the</strong> signed area of △ i ; see Figure 2. Now, if<br />

Ψ is convex <strong>the</strong>n all C i have <strong>the</strong> same sign (which depends on <strong>the</strong> orientation of Ψ) and<br />

so as long as all <strong>the</strong> weight functions b i are positive (or negative) <strong>the</strong>n W (v) can never<br />

be zero.<br />

4 Note that we always treat <strong>in</strong>dices cyclically with respect to each of <strong>the</strong> components <strong>in</strong> Ψ. Hence, if<br />

Ψ is a set of two polygons with n 1 and n 2 vertices, <strong>the</strong>n e n1 = (v n1 , v 1 ) and B n1 +1(v) is <strong>the</strong> area of<br />

[v, v n1 +n 2<br />

, v n1 +2].<br />

i=1<br />

Technical Report IfI-05-05


6 K. Hormann<br />

Figure 3: Zero-set of <strong>the</strong> denom<strong>in</strong>ator W (v) <strong>for</strong> <strong>the</strong> Wachspress (green) and <strong>the</strong> discrete<br />

harmonic coord<strong>in</strong>ates (red) <strong>for</strong> a concave polygon (black) and contour plots of <strong>the</strong><br />

normalized coord<strong>in</strong>ate function λ i that corresponds to <strong>the</strong> topmost vertex.<br />

But <strong>in</strong> <strong>the</strong> general case that we consider it is more difficult to avoid divid<strong>in</strong>g by zero.<br />

Consider, <strong>for</strong> example, <strong>the</strong> Wachspress and discrete harmonic coord<strong>in</strong>ates that can be<br />

generated by <strong>the</strong> weight functions<br />

b W i (v) =<br />

1<br />

A i−1 (v)A i (v)<br />

and b D i (v) =<br />

r i (v) 2<br />

A i−1 (v)A i (v) .<br />

Both coord<strong>in</strong>ates are well-def<strong>in</strong>ed <strong>for</strong> v <strong>in</strong>side any convex polygon. However, <strong>in</strong>side<br />

a non-convex polygon, W (v) can become zero, and <strong>the</strong> normalized coord<strong>in</strong>ates λ i (v)<br />

may have non-removable poles, as illustrated <strong>for</strong> a concave quadrilateral <strong>in</strong> Figure 3.<br />

To avoid this problem, Equation (9) suggests tak<strong>in</strong>g weight functions like b i (v) =<br />

1/C i so that W (v) = n. But although this particular choice gives well-def<strong>in</strong>ed (and<br />

l<strong>in</strong>ear) normalized coord<strong>in</strong>ates λ i as long as no three consecutive vertices of Ψ are<br />

coll<strong>in</strong>ear, <strong>the</strong>y un<strong>for</strong>tunately do not satisfy Equation (4).<br />

However, we found that <strong>the</strong> weight functions<br />

b i (v) =<br />

r i (v)<br />

A i−1 (v)A i (v)<br />

guarantee W (v) ≠ 0 <strong>for</strong> any v ∈ IR 2 (see Appendix B), and at <strong>the</strong> same time, <strong>the</strong><br />

correspond<strong>in</strong>g normalized coord<strong>in</strong>ates have <strong>the</strong> Lagrange property (see Appendix C).<br />

For this particular choice of b i , Equation (8) becomes<br />

w i (v) = r i−1(v)A i (v) − r i (v)B i (v) + r i+1 (v)A i−1 (v)<br />

, (10)<br />

A i−1 (v)A i (v)<br />

which we recognize as <strong>the</strong> mean value coord<strong>in</strong>ates <strong>in</strong> <strong>the</strong> <strong>for</strong>m given by Floater et al.<br />

(2005). By us<strong>in</strong>g (5) and (6) and some trigonometric identities this <strong>for</strong>mula simplifies<br />

to<br />

w i (v)<br />

2<br />

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

, (11)<br />

r i (v)<br />

which is <strong>the</strong> <strong>for</strong>mula that orig<strong>in</strong>ally appeared <strong>in</strong> (Floater, 2003).<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 7<br />

Let us now summarize <strong>the</strong> properties of <strong>the</strong> normalized barycentric coord<strong>in</strong>ates λ i<br />

that are def<strong>in</strong>ed by <strong>the</strong>se w i and Equation (3):<br />

1. Aff<strong>in</strong>e precision. It follows from (2) and (3) that<br />

n∑<br />

λ i (v)ϕ(v i ) = ϕ(v)<br />

i=1<br />

<strong>for</strong> any aff<strong>in</strong>e function ϕ : IR 2 → IR d and v ∈ IR 2 .<br />

2. Partition of unity. With ϕ(v) = 1 it follows immediately from <strong>the</strong> previous<br />

property that ∑ n<br />

i=1 λ i(v) = 1 <strong>for</strong> any v ∈ IR 2 .<br />

3. Lagrange property. The functions λ i satisfy λ i (v j ) = δ i,j (see Appendix C).<br />

4. L<strong>in</strong>earity property. The functions λ i are l<strong>in</strong>ear along <strong>the</strong> edges e j of Ψ (see<br />

Appendix C).<br />

5. L<strong>in</strong>ear <strong>in</strong>dependence. An immediate consequence of <strong>the</strong> previous property is<br />

that if ∑ n<br />

i=1 c iλ i (v) = 0 <strong>for</strong> all v ∈ IR 2 <strong>the</strong>n all c i must be zero.<br />

6. Smoothness. The functions λ i are C ∞ everywhere except at <strong>the</strong> vertices v j<br />

where <strong>the</strong>y are only C 0 (see Appendix C).<br />

7. Similarity <strong>in</strong>variance. S<strong>in</strong>ce <strong>the</strong> homogeneous coord<strong>in</strong>ates w i depend only on<br />

areas and distances and s<strong>in</strong>ce any uni<strong>for</strong>m scale factor cancels out <strong>in</strong> <strong>the</strong> normalization<br />

(3), it follows that if ϕ : IR 2 → IR 2 is a similarity trans<strong>for</strong>mation 5 and<br />

ˆλ i are <strong>the</strong> normalized barycentric coord<strong>in</strong>ates with respect to ̂Ψ = ϕ(Ψ), <strong>the</strong>n<br />

λ i (v) = ˆλ i (ϕ(v)).<br />

8. Locality. The homogeneous coord<strong>in</strong>ate function w i depends only on <strong>the</strong> vertices<br />

v i−1 , v i , and v i+1 of Ψ.<br />

9. Ref<strong>in</strong>ability. If we ref<strong>in</strong>e Ψ to ̂Ψ by add<strong>in</strong>g <strong>the</strong> vertex ˆv = (1 − µ)v j + µv j+1 ,<br />

and denote by ˆλ i and ˆλ <strong>the</strong> normalized barycentric coord<strong>in</strong>ates with respect to<br />

̂Ψ <strong>the</strong>n we have λ j = ˆλ j + (1 − µ)ˆλ, λ j+1 = ˆλ j+1 + µˆλ, and λ i = ˆλ i <strong>for</strong><br />

i ≠ j, j + 1 (see Appendix A).<br />

10. Positivity. It follows from (11) that <strong>the</strong> functions λ i are positive <strong>in</strong>side <strong>the</strong> kernel<br />

of a star-shaped polygon and <strong>in</strong> particular <strong>in</strong>side a convex polygon.<br />

Figure 4 illustrates <strong>the</strong> typical behaviour of <strong>the</strong> functions λ i <strong>for</strong> a set of simple polygons.<br />

The ma<strong>in</strong> application of <strong>the</strong>se generalized barycentric coord<strong>in</strong>ates is <strong>the</strong> <strong>in</strong>terpolation<br />

of values that are given at <strong>the</strong> vertices v i of Ψ. In o<strong>the</strong>r words, if a data value f i ∈ IR d<br />

is specified at each v i , <strong>the</strong>n we are <strong>in</strong>terested <strong>in</strong> <strong>the</strong> function F : IR 2 → IR d that is<br />

def<strong>in</strong>ed by<br />

n∑<br />

n∑<br />

F (v) = λ i (v)f i = w i (v)f i<br />

/W (v). (12)<br />

i=1<br />

i=1<br />

5 a translation, rotation, uni<strong>for</strong>m scal<strong>in</strong>g, or comb<strong>in</strong>ation of <strong>the</strong>se<br />

Technical Report IfI-05-05


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


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 9<br />

Figure 5: Colour <strong>in</strong>terpolation with generalized barycentric coord<strong>in</strong>ates <strong>for</strong> <strong>the</strong> polygons<br />

from Figure 4.<br />

function F (v)<br />

<strong>for</strong> i = 1 to n do<br />

s i := v i − v<br />

<strong>for</strong> i = 1 to n do<br />

r i := ‖s i ‖<br />

A i := det(s i , s i+1 )/2<br />

D i := 〈s i , s i+1 〉<br />

if r i = 0 <strong>the</strong>n<br />

// v = v i<br />

return f i<br />

if A i = 0 and D i < 0 <strong>the</strong>n // v ∈ e i<br />

r i+1 = ‖s i+1 ‖<br />

return (r i+1 f i + r i f i+1 )/(r i + r i+1 )<br />

f := 0<br />

W := 0<br />

<strong>for</strong> i = 1 to n do<br />

w := 0<br />

if A i−1 ≠ 0 <strong>the</strong>n<br />

w := w + (r i−1 − D i−1 /r i )/A i−1<br />

if A i ≠ 0 <strong>the</strong>n<br />

w := w + (r i+1 − D i /r i )/A i<br />

f := f + wf i<br />

W := W + w<br />

return f/W<br />

Figure 6: Pseudo-code <strong>for</strong> evaluat<strong>in</strong>g <strong>the</strong> <strong>in</strong>terpolation function.<br />

Technical Report IfI-05-05


10 K. Hormann<br />

(a)<br />

(b)<br />

(c)<br />

(d)<br />

Figure 7: Render<strong>in</strong>g of three pentagons with flat shad<strong>in</strong>g (a), Gouraud shad<strong>in</strong>g (b),<br />

Phong shad<strong>in</strong>g (c), and generalized Phong shad<strong>in</strong>g (d).<br />

5 Applications and Results<br />

We now present three applications of our generalized barycentric coord<strong>in</strong>ates that<br />

demonstrate <strong>the</strong>ir potential impact on computer graphics and geometric modell<strong>in</strong>g.<br />

5.1 Phong Shad<strong>in</strong>g <strong>for</strong> <strong>Arbitrary</strong> <strong>Polygons</strong><br />

The standard approach to treat<strong>in</strong>g an arbitrary polygon <strong>in</strong> <strong>the</strong> render<strong>in</strong>g pipel<strong>in</strong>e is to<br />

first tessellate it <strong>in</strong>to triangles and <strong>the</strong>n process each triangle <strong>in</strong> turn. For example,<br />

OpenGL automatically splits a pentagonal face <strong>in</strong>to three triangles. This gives <strong>the</strong> expected<br />

result if flat shad<strong>in</strong>g is used, but <strong>the</strong> splits become visible as soon as Gouraud<br />

shad<strong>in</strong>g or Phong shad<strong>in</strong>g is turned on; see Figure 7 (a–c).<br />

Phong shad<strong>in</strong>g uses triangular barycentric coord<strong>in</strong>ates to l<strong>in</strong>early <strong>in</strong>terpolate <strong>the</strong> normals<br />

that are given at <strong>the</strong> vertices of <strong>the</strong> face over each generated triangle. This can<br />

be seen <strong>for</strong> <strong>the</strong> two triangles that are marked by <strong>the</strong> green and blue spots <strong>in</strong> <strong>the</strong> Phongshaded<br />

result (c). S<strong>in</strong>ce <strong>the</strong> lower two vertices of both triangles have identical normals,<br />

<strong>the</strong> <strong>in</strong>terpolated normal as well as <strong>the</strong> result<strong>in</strong>g colour value vary l<strong>in</strong>early <strong>in</strong>side <strong>the</strong><br />

triangles. Instead, we can improve <strong>the</strong> idea of Phong shad<strong>in</strong>g and use <strong>the</strong> generalized<br />

barycentric coord<strong>in</strong>ates to smoothly <strong>in</strong>terpolate <strong>the</strong> normals over <strong>the</strong> whole polygon,<br />

giv<strong>in</strong>g a much more pleasant render<strong>in</strong>g result; see Figure 7 (d).<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 11<br />

(a) (b) (c)<br />

(d) (e) (f)<br />

(g) (h) (i)<br />

Figure 8: Flat (a), Gouraud (b), and Phong shad<strong>in</strong>g (c) of a simple triangle mesh. Generalized<br />

barycentric coord<strong>in</strong>ates can be used to smoothly <strong>in</strong>terpolate <strong>the</strong> vertices of <strong>the</strong><br />

exterior r<strong>in</strong>g of triangles (d) and <strong>the</strong>ir normals. The <strong>in</strong>terpolated normals can <strong>the</strong>n be<br />

used to shade <strong>the</strong> triangle mesh (e) or <strong>the</strong> <strong>in</strong>terpolated geometry (f). This approach can<br />

be extended to <strong>the</strong> <strong>in</strong>terior triangle fan (g–i).<br />

Ano<strong>the</strong>r example is shown <strong>in</strong> Figure 8. We first took <strong>the</strong> flat<br />

configuration on <strong>the</strong> right as a parameterization of <strong>the</strong> triangle<br />

mesh <strong>in</strong> (a) and regarded <strong>the</strong> two r<strong>in</strong>gs of vertices as polygons<br />

(thick l<strong>in</strong>es). Then we smoothly <strong>in</strong>terpolated <strong>the</strong> normals that were<br />

specified at <strong>the</strong>se vertices over <strong>the</strong> exterior r<strong>in</strong>g of triangles (grey<br />

area) with generalized barycentric coord<strong>in</strong>ates and used <strong>the</strong> result<br />

<strong>for</strong> a superior shad<strong>in</strong>g of <strong>the</strong> triangle mesh (e).<br />

The generalized barycentric coord<strong>in</strong>ates fur<strong>the</strong>r allowed us to <strong>in</strong>terpolate <strong>the</strong> vertex<br />

positions <strong>in</strong>stead of <strong>the</strong> normals and to create <strong>the</strong> smooth blend surface between <strong>the</strong><br />

two polygons that is shown <strong>in</strong> (d) with shad<strong>in</strong>g accord<strong>in</strong>g to <strong>the</strong> surface normal and<br />

<strong>in</strong> (f) with shad<strong>in</strong>g accord<strong>in</strong>g to <strong>the</strong> <strong>in</strong>terpolated normals. Of course, <strong>the</strong> <strong>in</strong>terpolation of<br />

normals and geometry is not limited to <strong>the</strong> grey region and can be extended to <strong>the</strong> whole<br />

triangle mesh (g–i). Note that <strong>the</strong> <strong>in</strong>terpolation surface <strong>in</strong> (g) is def<strong>in</strong>ed by all vertices<br />

of <strong>the</strong> triangle mesh except <strong>for</strong> <strong>the</strong> central vertex and <strong>the</strong>re<strong>for</strong>e does not necessarily pass<br />

through it.<br />

Technical Report IfI-05-05


12 K. Hormann<br />

(b)<br />

(a) (c) (d)<br />

Figure 9: The Lean<strong>in</strong>g Tower of Pisa (a) can be straightened by our barycentric warp<br />

function which maps <strong>the</strong> two source polygons (b) to <strong>the</strong> target polygons (c). The<br />

Straight Tower of Pisa is shown <strong>in</strong> (d).<br />

5.2 Image Warp<strong>in</strong>g<br />

Ano<strong>the</strong>r potential application of <strong>the</strong> generalized barycentric coord<strong>in</strong>ates is image warp<strong>in</strong>g<br />

as <strong>the</strong>y offer a particularly simple solution to this problem that can briefly be stated<br />

as follows.<br />

Given a rectangular region Ω, a set of source polygons Ψ with vertices v i ∈ Ω, and a<br />

topologically equivalent 6 set of target polygons ̂Ψ with vertices ˆv i ∈ Ω, we would like<br />

to construct a smooth warp function f : Ω → Ω that maps each v i to ˆv i . This warp<br />

function can <strong>the</strong>n be used to de<strong>for</strong>m a source image I : Ω → C that maps Ω to some<br />

colour space C <strong>in</strong>to a target image Î : Ω → C by simply sett<strong>in</strong>g Î = I ◦ f −1 . For<br />

practical reasons, <strong>the</strong> <strong>in</strong>verse mapp<strong>in</strong>g g = f −1 is often constructed <strong>in</strong>stead of f.<br />

Such an <strong>in</strong>verse warp function can easily be def<strong>in</strong>ed with <strong>the</strong> generalized barycentric<br />

coord<strong>in</strong>ates ˆλ i of ̂Ψ. It follows immediately from <strong>the</strong> Lagrange property that <strong>the</strong><br />

function g : IR 2 → IR 2 with<br />

n∑<br />

g(x) = ˆλ(x)v i (13)<br />

i=1<br />

maps each ˆv i to v i and thus def<strong>in</strong>es a proper <strong>in</strong>verse warp function. The warped image<br />

can now be generated by simply sett<strong>in</strong>g <strong>the</strong> colour of each target pixel x <strong>in</strong> Î to<br />

<strong>the</strong> colour of <strong>the</strong> source po<strong>in</strong>t g(x) <strong>in</strong> I. In our examples we used a simple bil<strong>in</strong>ear<br />

<strong>in</strong>terpolation to determ<strong>in</strong>e I(g(x)) from <strong>the</strong> 2×2 grid of pixels surround<strong>in</strong>g g(x).<br />

Like warp<strong>in</strong>g with B-spl<strong>in</strong>es and radial basis functions with l<strong>in</strong>ear precision, this<br />

barycentric warp reproduces aff<strong>in</strong>e trans<strong>for</strong>mations. In o<strong>the</strong>r words, if ϕ : IR 2 → IR 2<br />

is an aff<strong>in</strong>e trans<strong>for</strong>mation and ̂Ψ = ϕ(Ψ) <strong>the</strong>n Î = I ◦ ϕ−1 . Indeed, s<strong>in</strong>ce v i =<br />

ϕ −1 (ˆv i ) it follows from <strong>the</strong> aff<strong>in</strong>e precision property of <strong>the</strong> barycentric coord<strong>in</strong>ates that<br />

g(x) = ϕ −1 (x) <strong>in</strong> (13).<br />

6 with <strong>the</strong> same number of vertices and components<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 13<br />

(a)<br />

(b)<br />

(c)<br />

(d)<br />

Figure 10: Warp<strong>in</strong>g an image (a) with generalized barycentric coord<strong>in</strong>ates (b) and radial<br />

basis functions (c,d) by mov<strong>in</strong>g <strong>the</strong> vertices of two nested polygons (blue).<br />

Ano<strong>the</strong>r property of <strong>the</strong> barycentric warp is that it is l<strong>in</strong>ear along <strong>the</strong> edges of <strong>the</strong><br />

polygons. Figure 10 (b) shows <strong>the</strong> result of warp<strong>in</strong>g <strong>the</strong> image <strong>in</strong> (a) after mov<strong>in</strong>g <strong>the</strong><br />

vertices of two nested polygons. The exterior polygon with 14 vertices controls <strong>the</strong><br />

global shape of <strong>the</strong> warp, while <strong>the</strong> <strong>in</strong>terior polygon with 10 vertices is used to de<strong>for</strong>m<br />

<strong>the</strong> star. The result is smooth and <strong>the</strong> star is clearly mapped to a star with straight edges.<br />

For comparison, we also generated <strong>the</strong> th<strong>in</strong> plate spl<strong>in</strong>e warp (c) us<strong>in</strong>g radial basis<br />

<strong>in</strong>terpolation with basis function φ(r) = r 2 log r (see Arad et al. (1994) <strong>for</strong> details).<br />

This warp does not reproduce <strong>the</strong> straight edges of <strong>the</strong> star, but a common trick to<br />

overcome this drawback is to sample <strong>the</strong> edges with additional vertices. For example,<br />

by tak<strong>in</strong>g 20 samples per edge, we obta<strong>in</strong>ed <strong>the</strong> result <strong>in</strong> (d). It is very similar to <strong>the</strong><br />

barycentric warp, but takes considerably longer to compute: 20 seconds <strong>for</strong> a 600×600<br />

image on a 2.8 Ghz Pentium, while <strong>the</strong> barycentric warp took less than one second.<br />

Technical Report IfI-05-05


14 K. Hormann<br />

This is due to <strong>the</strong> large l<strong>in</strong>ear system that needs to be solved and <strong>the</strong> large number<br />

of basis functions that have to be evaluated. In general, if n is <strong>the</strong> number of vertices<br />

<strong>in</strong> Ψ and k is <strong>the</strong> number of samples per edge, <strong>the</strong>n solv<strong>in</strong>g <strong>the</strong> l<strong>in</strong>ear system with a<br />

standard method is an O(k 3 · n 3 ) operation and evaluat<strong>in</strong>g <strong>the</strong> m pixels of Î is of order<br />

O(m·k·n). Of course <strong>the</strong>re exist specialized solvers that can reduce <strong>the</strong> cost <strong>for</strong> solv<strong>in</strong>g<br />

<strong>the</strong> l<strong>in</strong>ear system, but <strong>the</strong> advantage of <strong>the</strong> barycentric warp is that it does not require<br />

any system to be solved and <strong>the</strong> whole computation is of order O(m · n) only.<br />

We conclude that <strong>the</strong> barycentric warp is particularly useful whenever straight edges<br />

need to be preserved. For example, mak<strong>in</strong>g <strong>the</strong> boundary of <strong>the</strong> rectangular image<br />

one of <strong>the</strong> source and <strong>the</strong> target polygons guarantees that <strong>the</strong> warped image will be<br />

rectangular too; see Figure 9.<br />

5.3 Transf<strong>in</strong>ite Interpolation<br />

Our generalized barycentric coord<strong>in</strong>ates also provide an efficient solution to <strong>the</strong> follow<strong>in</strong>g<br />

<strong>in</strong>terpolation problem. Given a set of closed planar curves c j and some<br />

d-dimensional data over <strong>the</strong>se curves d j : c j → IR d we would like to have a function<br />

F : IR 2 → IR d that <strong>in</strong>terpolates <strong>the</strong> given data, i.e. F (v) = d j (v) <strong>for</strong> any v ∈ c j .<br />

The obvious approach is to approximate <strong>the</strong> given curves c j with a set of polygons<br />

Ψ whose vertices v i lie on <strong>the</strong> curves c j . Then <strong>the</strong> function F <strong>in</strong> Equation (12) with<br />

f i = d j (v i ) clearly is an approximate solution of <strong>the</strong> stated <strong>in</strong>terpolation problem. And<br />

as <strong>the</strong> polygons Ψ converge to <strong>the</strong> curves c j by <strong>in</strong>creas<strong>in</strong>g <strong>the</strong> sampl<strong>in</strong>g density, so does<br />

<strong>the</strong> function F converge to <strong>the</strong> desired solution.<br />

The <strong>in</strong>terest<strong>in</strong>g fact now is that <strong>the</strong> structure of our generalized barycentric coord<strong>in</strong>ates<br />

allows an efficient update of <strong>the</strong> solution if <strong>the</strong> sampl<strong>in</strong>g density is <strong>in</strong>creased.<br />

Assume that we computed F (v) and also W (v) from Equation (9) <strong>for</strong> some polygon Ψ<br />

and <strong>the</strong>n ref<strong>in</strong>e Ψ to ̂Ψ by add<strong>in</strong>g a vertex ˆv with data value ˆf = d j (ˆv) between v j and<br />

v j+1 . Then it follows from Appendix A that <strong>the</strong> ref<strong>in</strong>ed <strong>in</strong>terpolation function ̂F (v) can<br />

be written as<br />

with<br />

̂F (v) = F (v) + ŵ(v)<br />

Ŵ (v) ( ˆf − ρ(v)F (v) − σ(v)f j − τ(v)f j+1 ) (14)<br />

Ŵ (v) = W (v) + ρ(v)ŵ(v) (15)<br />

where ŵ(v) is <strong>the</strong> new homogeneous coord<strong>in</strong>ate function <strong>for</strong> ˆv and ρ(v), σ(v), and τ(v)<br />

are <strong>the</strong> normalized barycentric coord<strong>in</strong>ates of ˆv with respect to <strong>the</strong> triangle [v, v j , v j+1 ].<br />

Note that ρ, σ, and τ can be computed from <strong>the</strong> same <strong>in</strong>gredients as ŵ.<br />

In <strong>the</strong> example <strong>in</strong> Figure 11, we exploited this recurrence relation as follows. We<br />

first sampled <strong>the</strong> three given curves uni<strong>for</strong>mly with 100 vertices v i and computed <strong>the</strong><br />

curve normals n i at v i . Then we evaluated <strong>the</strong> <strong>in</strong>terpolat<strong>in</strong>g function F as well as W<br />

on a regular 512×512 grid, yield<strong>in</strong>g values F kl and W kl with 0 ≤ k, l ≤ 511. We<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 15<br />

(a)<br />

(b)<br />

Figure 11: Three curves with normal vectors (a) and a LIC visualization of <strong>the</strong> <strong>in</strong>terpolated<br />

vector field (b). The colour refers to <strong>the</strong> length l of <strong>the</strong> vectors (white: l = 1,<br />

blue: l > 1, red: l < 1).<br />

f<strong>in</strong>ally ref<strong>in</strong>ed Ψ successively by splitt<strong>in</strong>g <strong>the</strong> edge with <strong>the</strong> largest approximation error<br />

to <strong>the</strong> curve and updated F kl and W kl accord<strong>in</strong>g to (14) and (15). We stopped <strong>the</strong><br />

ref<strong>in</strong>ement process as soon as max k,l ‖ ̂F kl − F kl ‖ < 0.001, i.e. when <strong>the</strong> maximum<br />

update went below 1% of <strong>the</strong> length of <strong>the</strong> given vectors. The f<strong>in</strong>al polygon consisted<br />

of 357 vertices and it took about 10 seconds to compute <strong>the</strong> f<strong>in</strong>al values F kl .<br />

Ano<strong>the</strong>r example where we <strong>in</strong>terpolated height data is shown <strong>in</strong> Figure 12. We first<br />

used Shewchuk’s triangle program (Shewchuk, 2002) to generate a regular triangulation<br />

of <strong>the</strong> doma<strong>in</strong> and <strong>the</strong> 2,500 vertices and edges of Ψ. Then we evaluated <strong>the</strong> <strong>in</strong>terpolat<strong>in</strong>g<br />

function at <strong>the</strong> 100,000 vertices of this constra<strong>in</strong>ed Delaunay triangulation, which<br />

took about 25 seconds. We also computed <strong>the</strong> <strong>in</strong>terpolat<strong>in</strong>g th<strong>in</strong> plate spl<strong>in</strong>e <strong>for</strong> comparison<br />

and found <strong>the</strong> height difference between both surfaces to be less than 10% of<br />

<strong>the</strong> maximum value.<br />

6 Conclusions<br />

We have presented a natural generalization of triangular barycentric coord<strong>in</strong>ates both<br />

to arbitrary polygons and even to sets of polygons. Our generalized barycentric coord<strong>in</strong>ates<br />

have a number of important properties and are particularly useful <strong>for</strong> <strong>the</strong> <strong>in</strong>terpolation<br />

of data that is given at <strong>the</strong> vertices of <strong>the</strong> polygons. As shown <strong>in</strong> Figures 10<br />

and 12, <strong>the</strong> behaviour of <strong>the</strong> <strong>in</strong>terpolant is strik<strong>in</strong>gly similar to that of th<strong>in</strong> plate spl<strong>in</strong>es.<br />

However, unlike th<strong>in</strong> plate spl<strong>in</strong>es, our <strong>in</strong>terpolant is extremely fast to evaluate. In our<br />

Technical Report IfI-05-05


16 K. Hormann<br />

(a)<br />

(b)<br />

(c)<br />

(d)<br />

Figure 12: Interpolation of height values (red) that are given as smooth functions over<br />

<strong>the</strong> four curves <strong>in</strong> (a) with generalized barycentric coord<strong>in</strong>ates (b) and with a th<strong>in</strong> plate<br />

spl<strong>in</strong>e (c). The difference of both surfaces is shown <strong>in</strong> (d).<br />

implementation we have typically seen around 10,000,000 evaluations of <strong>the</strong> coord<strong>in</strong>ates<br />

λ i per second.<br />

We note that, <strong>in</strong> contrast to Sibson’s coord<strong>in</strong>ates <strong>for</strong> scattered data, our coord<strong>in</strong>ates<br />

have global support and are not everywhere positive <strong>in</strong> <strong>the</strong> case of arbitrary polygons.<br />

On <strong>the</strong> o<strong>the</strong>r hand it is probably due to <strong>the</strong>se properties that our <strong>in</strong>terpolants behave so<br />

nicely. In <strong>the</strong> context of image warp<strong>in</strong>g, this lack of positivity means that our barycentric<br />

warp function is not guaranteed to be one-to-one, except if both <strong>the</strong> source and <strong>the</strong><br />

target polygon are convex. But never<strong>the</strong>less <strong>the</strong> method appears to work very well <strong>in</strong><br />

practice.<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 17<br />

7 Future Work<br />

An <strong>in</strong>terest<strong>in</strong>g question <strong>for</strong> future research is whe<strong>the</strong>r our generalized barycentric coord<strong>in</strong>ates<br />

can be implemented <strong>in</strong> <strong>the</strong> graphics hardware to fur<strong>the</strong>r speed up <strong>the</strong> computation.<br />

This would be useful <strong>for</strong> image warp<strong>in</strong>g and even more <strong>for</strong> our improved Phong<br />

shad<strong>in</strong>g. The algorithm <strong>for</strong> evaluat<strong>in</strong>g <strong>the</strong> <strong>in</strong>terpolation function seems to be simple<br />

enough to be coded <strong>in</strong> <strong>the</strong> fragment shader of <strong>the</strong> GPU and could fur<strong>the</strong>r be simplified<br />

because <strong>the</strong> entities s i (v) and A i (v) are l<strong>in</strong>ear functions and dest<strong>in</strong>ed to be generated<br />

by <strong>the</strong> rasterizer through l<strong>in</strong>ear <strong>in</strong>terpolation of <strong>the</strong> values computed at <strong>the</strong> vertices v i .<br />

However, as long as <strong>the</strong> graphics hardware does not provide loops and <strong>the</strong> code must<br />

<strong>the</strong>re<strong>for</strong>e be replicated n times, and as long as <strong>the</strong> code length of programs on <strong>the</strong> GPU<br />

is restricted, <strong>the</strong> implementation will be limited to work only <strong>for</strong> small n.<br />

We also plan to <strong>in</strong>vestigate two very promis<strong>in</strong>g extensions of our coord<strong>in</strong>ates. Firstly,<br />

we are confident that <strong>the</strong>y can be generalized to polyhedra of arbitrary genus <strong>in</strong> 3D,<br />

lead<strong>in</strong>g to an analogous transf<strong>in</strong>ite <strong>in</strong>terpolation of data over closed surfaces. Secondly,<br />

we believe that our barycentric coord<strong>in</strong>ates can be generalized from polygons to smooth<br />

closed curves or sets of curves <strong>in</strong> <strong>the</strong> plane. We will thoroughly analyse <strong>the</strong> ma<strong>the</strong>matical<br />

and computational aspects of both of <strong>the</strong>se generalizations.<br />

F<strong>in</strong>ally, we would like to be able to <strong>in</strong>terpolate data over curves, where not only<br />

height data are specified but also tangent data, and possibly higher order derivatives.<br />

Our coord<strong>in</strong>ates do not currently allow such Hermite <strong>in</strong>terpolation, but we have some<br />

ideas on how this might be achieved, and we will explore <strong>the</strong>se <strong>in</strong> future work.<br />

References<br />

Arad, N., Dyn, N., Reisfeld, D., and Yeshurun, Y. (1994). Image warp<strong>in</strong>g by radial<br />

basis functions: Application to facial expressions. CVGIP: Graphical Models and<br />

Image Process<strong>in</strong>g, 56(2):161–172.<br />

Beatson, R. K., Cherrie, J. B., and Mouat, C. T. (1999). Fast fitt<strong>in</strong>g of radial basis<br />

functions: Methods based on preconditioned GMRES iteration. Advances <strong>in</strong> Computational<br />

Ma<strong>the</strong>matics, 11(2-3):253–270.<br />

Buhmann, M. (2000). Radial basis functions: <strong>the</strong> state-of-<strong>the</strong>-art and new results. Acta<br />

Numerica, 9:1–37.<br />

Ceva, G. (1678). De l<strong>in</strong>eis rectis se <strong>in</strong>vicem secantibus, statica constructio. Ludovici<br />

Montiae, Mediolanum.<br />

Chai, J., Miyoshi, T., and Nakamae, E. (1998). Contour <strong>in</strong>terpolation and surface reconstruction<br />

of smooth terra<strong>in</strong> models. In Proceed<strong>in</strong>gs of <strong>the</strong> Conference on Visualization<br />

’98, pages 27–33.<br />

Technical Report IfI-05-05


18 K. Hormann<br />

Coxeter, H. S. M. (1969). Introduction to Geometry, chapter 13.7, <strong>Barycentric</strong> coord<strong>in</strong>ates,<br />

pages 216–221. Wiley, New York, second edition.<br />

Eck, M., DeRose, T., Duchamp, T., Hoppe, H., Lounsbery, M., and Stuetzle, W. (1995).<br />

Multiresolution analysis of arbitrary meshes. In Proceed<strong>in</strong>gs of SIGGRAPH ’95,<br />

pages 173–182.<br />

Far<strong>in</strong>, G. (1990). Surfaces over Dirichlet tessellations. Computer Aided Geometric<br />

Design, 7(1-4):281–292.<br />

Far<strong>in</strong>, G. (2002). Curves and Surfaces <strong>for</strong> CAGD: A Practical Guide. The Morgan<br />

Kaufmann Series <strong>in</strong> Computer Graphics and Geometric Model<strong>in</strong>g. Morgan Kaufmann,<br />

San Francisco, fifth edition.<br />

Floater, M. S. (2003). Mean value coord<strong>in</strong>ates. Computer Aided Geometric Design,<br />

20(1):19–27.<br />

Floater, M. S., Hormann, K., and Kós, G. (2005). A general construction of barycentric<br />

coord<strong>in</strong>ates over convex polygons. Advances <strong>in</strong> Computational Ma<strong>the</strong>matics. To<br />

appear.<br />

Glasbey, C. A. and Mardia, K. V. (1998). A review of image warp<strong>in</strong>g methods. Journal<br />

of Applied Statistics, 25(2):155–171.<br />

Gross, L. and Far<strong>in</strong>, G. (1999). A transf<strong>in</strong>ite <strong>for</strong>m of Sibson’s <strong>in</strong>terpolant. Discrete<br />

Applied Ma<strong>the</strong>matics, 93(1):33–50.<br />

Hiyoshi, H. and Sugihara, K. (2000). Voronoi-based <strong>in</strong>terpolation with higher cont<strong>in</strong>uity.<br />

In Proceed<strong>in</strong>gs of <strong>the</strong> sixteenth annual symposium on Computational geometry,<br />

pages 242–250.<br />

Kounchev, O. (2001). Multivariate Polyspl<strong>in</strong>es: Applications to Numerical and Wavelet<br />

Analysis. Academic Press, London, San Diego.<br />

Lee, S., Chwa, K.-Y., Sh<strong>in</strong>, S. Y., and Wolberg, G. (1995). Image metamorphosis us<strong>in</strong>g<br />

snakes and free-<strong>for</strong>m de<strong>for</strong>mations. In Proceed<strong>in</strong>gs of SIGGRAPH ’95, pages 439–<br />

448.<br />

Lee, S., Wolberg, G., and Sh<strong>in</strong>, S. Y. (1997). Scattered data <strong>in</strong>terpolation with multilevel<br />

B-spl<strong>in</strong>es. IEEE Transactions on Visualization and Computer Graphics, 3(3):228–<br />

244.<br />

Malsch, E. A. and Dasgupta, G. (2004a). Algebraic construction of smooth <strong>in</strong>terpolants<br />

on polygonal doma<strong>in</strong>s. The Ma<strong>the</strong>matica Journal, 9(3).<br />

Malsch, E. A. and Dasgupta, G. (2004b). Interpolations <strong>for</strong> temperature distributions: A<br />

method <strong>for</strong> all non-concave polygons. International Journal of Solids and Structures,<br />

41(8):2165–2188.<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 19<br />

Meyer, M., Lee, H., Barr, A. H., and Desbrun, M. (2002). Generalized barycentric<br />

coord<strong>in</strong>ates on irregular polygons. Journal of Graphics Tools, 7(1):13–22.<br />

Milliron, T., Jensen, R. J., Barzel, R., and F<strong>in</strong>kelste<strong>in</strong>, A. (2002). A framework <strong>for</strong><br />

geometric warps and de<strong>for</strong>mations. ACM Transactions on Graphics, 21(1):20–51.<br />

Möbius, A. F. (1827). Der barycentrische Calcul. Johann Ambrosius Barth, Leipzig.<br />

Nürnberger, G. and Zeilfelder, F. (2000). Developments <strong>in</strong> bivariate spl<strong>in</strong>e <strong>in</strong>terpolation.<br />

Journal of Computational and Applied Ma<strong>the</strong>matics, 121(1-2):125–152.<br />

P<strong>in</strong>kall, U. and Polthier, K. (1993). Comput<strong>in</strong>g discrete m<strong>in</strong>imal surfaces and <strong>the</strong>ir<br />

conjugates. Experimental Ma<strong>the</strong>matics, 2(1):15–36.<br />

Ruprecht, D. and Müller, H. (1995). Image warp<strong>in</strong>g with scattered data <strong>in</strong>terpolation.<br />

IEEE Computer Graphics and Applications, 15(2):37–43.<br />

Shewchuk, J. R. (2002). Delaunay ref<strong>in</strong>ement algorithms <strong>for</strong> triangular mesh generation.<br />

Computational Geometry: Theory and Applications, 22(1-3):21–74.<br />

Sibson, R. (1980). A vector identity <strong>for</strong> <strong>the</strong> Dirichlet tesselation. Ma<strong>the</strong>matical Proceed<strong>in</strong>gs<br />

of <strong>the</strong> Cambridge Philosophical Society, 87:151–155.<br />

Sibson, R. (1981). A brief description of natural neighbour <strong>in</strong>terpolation. In Barnett,<br />

V., editor, Interpolat<strong>in</strong>g Multivariate Data, pages 21–36. Wiley, New York.<br />

Wachspress, E. L. (1975). A Rational F<strong>in</strong>ite Element Basis. Academic Press, New<br />

York.<br />

Warren, J. (1996). <strong>Barycentric</strong> coord<strong>in</strong>ates <strong>for</strong> convex polytopes. Advances <strong>in</strong> Computational<br />

Ma<strong>the</strong>matics, 6(2):97–108.<br />

Warren, J. (2003). On <strong>the</strong> uniqueness of barycentric coord<strong>in</strong>ates. In Contemporary<br />

Ma<strong>the</strong>matics, Proceed<strong>in</strong>gs of AGGM ’02, pages 93–99.<br />

Warren, J., Schaefer, S., Hirani, A. N., and Desbrun, M. (2003). <strong>Barycentric</strong> coord<strong>in</strong>ates<br />

<strong>for</strong> convex sets. Technical report, Rice University.<br />

Wolberg, G. (1990). Digital Image Warp<strong>in</strong>g. IEEE Computer Society Press, Los Alamitos.<br />

Technical Report IfI-05-05


20 K. Hormann<br />

v j+2<br />

v<br />

Ψ^<br />

r j+1<br />

α j+1<br />

^<br />

α α +<br />

r^<br />

j ^<br />

α j–1<br />

α –<br />

r j<br />

v j–1<br />

v^<br />

v j<br />

v j+1<br />

Figure 13: Notation <strong>for</strong> ref<strong>in</strong><strong>in</strong>g a polygon by add<strong>in</strong>g a vertex.<br />

A<br />

Ref<strong>in</strong>ability<br />

If we ref<strong>in</strong>e <strong>the</strong> polygon Ψ to ̂Ψ by add<strong>in</strong>g a vertex ˆv between v j and v j+1 as <strong>in</strong> Figure<br />

13, <strong>the</strong>n it follows from <strong>the</strong> locality of <strong>the</strong> homogeneous coord<strong>in</strong>ates that ŵ i = w i<br />

<strong>for</strong> i ≠ j, j + 1. Accord<strong>in</strong>g to Equation (11), <strong>the</strong> o<strong>the</strong>r three homogeneous coord<strong>in</strong>ates<br />

are<br />

ŵ j (v) = 2 ( tan(α j−1 (v)/2) + tan(̂α − (v)/2) ) /r j (v),<br />

ŵ(v) = 2 ( tan(̂α − (v)/2) + tan(̂α + (v)/2) ) /ˆr(v),<br />

ŵ j (v) = 2 ( tan(̂α + (v)/2) + tan(α j+1 (v)/2) ) /r j+1 (v).<br />

If we now write ˆv as an aff<strong>in</strong>e comb<strong>in</strong>ation of v, v j , and v j+1 , i.e.,<br />

with barycentric coord<strong>in</strong>ates<br />

and<br />

ˆv = ρ(v)v + σ(v)v j + τ(v)v j+1<br />

σ(v) = ˆr(v) s<strong>in</strong> ̂α+ (v)<br />

r j (v) s<strong>in</strong> α j (v) , τ(v) = ˆr(v) s<strong>in</strong> ̂α− (v)<br />

r j+1 (v) s<strong>in</strong> α j (v) ,<br />

ρ(v) = 1 − σ(v) − τ(v),<br />

<strong>the</strong>n some elementary trans<strong>for</strong>mations show that <strong>the</strong> homogeneous coord<strong>in</strong>ates w j and<br />

w j+1 can be expressed as<br />

w j (v) = ŵ j (v) + σ(v)ŵ(v),<br />

w j+1 (v) = ŵ j+1 (v) + τ(v)ŵ(v),<br />

and that <strong>the</strong> sum of <strong>the</strong> ref<strong>in</strong>ed homogeneous coord<strong>in</strong>ates satisfies<br />

Ŵ (v) = W (v) + ρ(v)ŵ(v).<br />

It fur<strong>the</strong>r follows that Ŵ (v) = W (v) <strong>in</strong> <strong>the</strong> special case that ˆv lies on <strong>the</strong> edge e j =<br />

(v j , v j+1 ) s<strong>in</strong>ce <strong>the</strong>n ρ(v) = 0.<br />

INSTITUT FÜR INFORMATIK


BARYCENTRIC COORDINATES FOR ARBITRARY POLYGONS 21<br />

+<br />

–<br />

–<br />

+<br />

+<br />

–<br />

v i+1<br />

e i<br />

v i<br />

e v<br />

j j<br />

v j+1<br />

v<br />

(a)<br />

(b)<br />

Figure 14: Interior and orientation of a set of polygons (a) and partition<strong>in</strong>g <strong>in</strong>to sectors<br />

(b) with exit (solid) and entry edges (dashed).<br />

B<br />

Normalization<br />

The most important property of our homogeneous coord<strong>in</strong>ates is that <strong>the</strong>ir sum W (v)<br />

is never zero <strong>for</strong> any v /∈ Ψ and <strong>the</strong>re<strong>for</strong>e <strong>the</strong> normalization <strong>in</strong> (3) is well-def<strong>in</strong>ed. We<br />

can even show that W (v) is positive <strong>in</strong> <strong>the</strong> <strong>in</strong>terior of Ψ and negative o<strong>the</strong>rwise. For a<br />

set of polygons like <strong>in</strong> Figure 14 (a) we def<strong>in</strong>e <strong>the</strong> grey region as <strong>the</strong> <strong>in</strong>terior and fur<strong>the</strong>r<br />

assume <strong>the</strong> polygons to be orientated as <strong>in</strong>dicated.<br />

Now, let v be a vertex <strong>in</strong>side Ψ. We first consider <strong>the</strong> rays from v through <strong>the</strong><br />

vertices v i and add all <strong>in</strong>tersection po<strong>in</strong>ts to Ψ as shown <strong>in</strong> Figure 14 (b). Accord<strong>in</strong>g<br />

to Appendix A this does not change W (v). Next we consider <strong>for</strong> any of <strong>the</strong> radial<br />

sectors between two neighbour<strong>in</strong>g rays all edges <strong>in</strong>side <strong>the</strong> sector and classify <strong>the</strong>m<br />

as exit edges (solid) or entry edges (dashed), depend<strong>in</strong>g on whe<strong>the</strong>r a traveller com<strong>in</strong>g<br />

from v exits or enters <strong>the</strong> <strong>in</strong>terior of Ψ at <strong>the</strong> edge. If we <strong>the</strong>n def<strong>in</strong>e <strong>for</strong> each edge<br />

e i = (v i , v i+1 ) <strong>the</strong> value<br />

( 1<br />

κ i = + 1 )<br />

tan(α i /2).<br />

r i r i+1<br />

<strong>the</strong>n it follows from <strong>the</strong> orientation of Ψ that κ i is positive if e i is an exit edge and<br />

negative if e i is an entry edge. And <strong>for</strong> edges e i that lie on one of <strong>the</strong> rays, we have<br />

κ i = 0.<br />

Now let e i be one of <strong>the</strong> entry edges. Then <strong>the</strong>re always exists an exit edge e j <strong>in</strong> <strong>the</strong><br />

same sector that is closer to v; see Figure 14 (b). But as α i = −α j and at least one of<br />

<strong>the</strong> <strong>in</strong>equalities r j ≤ r i+1 and r j+1 ≤ r i is strict, we have<br />

κ j =<br />

( 1<br />

r j<br />

+ 1<br />

r j+1<br />

)<br />

tan(α j /2) ><br />

( 1<br />

r i<br />

+ 1<br />

r i+1<br />

)<br />

tan(−α i /2) = −κ i .<br />

This means that <strong>the</strong> negative κ i of <strong>the</strong> entry edge e i is counterbalanced by <strong>the</strong> positive<br />

κ j of <strong>the</strong> exit edge e j . As this holds <strong>for</strong> all entry edges (without us<strong>in</strong>g any exit edge<br />

Technical Report IfI-05-05


22 K. Hormann<br />

twice) and also <strong>in</strong> <strong>the</strong> case that Ψ is a set of (possibly nested) polygons, we conclude<br />

that<br />

n∑<br />

κ i > 0.<br />

i=1<br />

But <strong>the</strong> sum of <strong>the</strong> κ i can be rearranged, by a change of summation <strong>in</strong>dex, to be half <strong>the</strong><br />

sum of <strong>the</strong> w i (v) <strong>in</strong> <strong>the</strong> <strong>for</strong>m of Equation (11) and <strong>the</strong>re<strong>for</strong>e W (v) is positive <strong>for</strong> any v<br />

<strong>in</strong>side Ψ. Likewise one can show that W (v) is negative over <strong>the</strong> exterior of Ψ.<br />

C<br />

Lagrange and L<strong>in</strong>earity Property<br />

From <strong>the</strong> representation of <strong>the</strong> homogeneous coord<strong>in</strong>ates <strong>in</strong> Equation (11) it follows<br />

that w i (v) is C ∞ everywhere except at <strong>the</strong> vertices v i−1 , v i , v i+1 and <strong>the</strong> edges e i−1 ,<br />

e i . As a consequence, <strong>the</strong> normalized coord<strong>in</strong>ates λ i (v) are C ∞ at all v /∈ Ψ. To study<br />

<strong>the</strong> behaviour of λ i on one of <strong>the</strong> edges e j of Ψ, we consider <strong>the</strong> slightly modified<br />

homogeneous coord<strong>in</strong>ates<br />

ŵ i (v) = w i (v)A j (v) = r j(v)r j+1 (v)<br />

(z i−1 (v) + z i (v)),<br />

r i (v)<br />

where z i (v) = tan(α i (v)/2) s<strong>in</strong>(α j (v))/2. Then we have <strong>for</strong> any v ∈ e j that z i (v) = 0<br />

<strong>for</strong> i ≠ j and z j (v) = 1 and <strong>the</strong>re<strong>for</strong>e ŵ j (v) = r j+1 (v), ŵ j+1 (v) = r j (v), and<br />

ŵ i (v) = 0 <strong>for</strong> i ≠ j, j + 1. It follows that λ i (v) = 0 <strong>for</strong> all i ≠ j, j + 1 and<br />

λ j (v) =<br />

r j+1 (v)<br />

r j (v) + r j+1 (v) , λ r j (v)<br />

j+1(v) =<br />

r j (v) + r j+1 (v) ,<br />

which are <strong>the</strong> standard barycentric coord<strong>in</strong>ates on an edge, converg<strong>in</strong>g to δ ij as v approaches<br />

v j . Fur<strong>the</strong>r it is clear that <strong>the</strong> functions ŵ i are C ∞ over e j and so are <strong>the</strong> λ i .<br />

INSTITUT FÜR INFORMATIK


Impressum<br />

Publisher: Institut für In<strong>for</strong>matik, Technische Universität Clausthal<br />

Julius-Albert Str. 4, 38678 Clausthal-Zellerfeld, Germany<br />

Editor of <strong>the</strong> series: Jürgen Dix<br />

Technical editor: Wojciech Jamroga<br />

Contact: wjamroga@<strong>in</strong>.tu-clausthal.de<br />

URL: http://www.<strong>in</strong>.tu-clausthal.de/ ∼ wjamroga/techreports/<br />

The IfI Review Board<br />

Prof. Dr. Jürgen Dix (Theoretical Computer Science/Computational Intelligence)<br />

Prof. Dr. Klaus Ecker (Applied Computer Science)<br />

Prof. Dr. habil. Torsten Grust (Databases)<br />

Prof. Dr. Barbara Hammer (Theoretical Foundations of Computer Science)<br />

Prof. Dr. Kai Hormann (Computer Graphics)<br />

Dr. Michaela Huhn (Economical Computer Science)<br />

Prof. Dr. Gerhard R. Joubert (Practical Computer Science)<br />

Prof. Dr. Ingbert Kupka (Theoretical Computer Science)<br />

Prof. Dr. Wilfried Lex (Ma<strong>the</strong>matical Foundations of Computer Science)<br />

Prof. Dr. Jörg Müller (Agent Systems)<br />

Prof. Dr.-Ing. Dr. rer. nat. habil. Harald Richter (Technical Computer Science)<br />

Prof. Dr. Gabriel Zachmann (Virtual Reality)

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

Saved successfully!

Ooh no, something went wrong!