Barycentric and harmonic coordinates Petter Lidberg U.U.D.M. Project Report 2012:18 Department of Mathematics

Barycentric and harmonic coordinates Petter Lidberg U.U.D.M. Project Report 2012:18 Department of Mathematics
U.U.D.M. Project Report 2012:18
Barycentric and harmonic coordinates
Petter Lidberg
Examensarbete i matematik, 30 hp
Handledare och examinator: Vera Koponen
Augusti 2012
Department of Mathematics
Uppsala University
Abstract
Barycentric coordinates are widely used in computer graphics. Because of barycentric coordinates’ great properties and applications, the problem of generalising
them to work with polygons or polyhedrons instead of triangles or tetrahedrons,
has been the subject of intense research within the community.
In 2007 Pixar Animation Studio introduced their solution of generalizing barycentric coordinates, named: Harmonic coordinates. Harmonic coordinates have all
the great properties of barycentric coordinates and significantly improve previous
generalizations of barycentric coordinates. Harmonic coordinates spring from the
solutions of the classical Dirichlet problem; that use the Laplace’s equation as its
core partial differential equation together with a certain top-hat function for its
boundary conditions.
Because of this, harmonic coordinates lack a closed formed expression and need to
be computed using a brute force computational approach. Also, because of the use
of Laplace’s equation, harmonic coordinates are closely linked to harmonic function theory.
The aim of this paper is to explain barycentric and harmonic coordinates and to
put them in a proper mathematical context. This paper will provide proofs of the
key properties of barycentric and harmonic coordinates. This paper will also identify the key propositions from harmonic function theory used in the construction
of harmonic coordinates. Furthermore, this paper will show that harmonic coordinates are in fact a classic Dirichlet problem.
Keywords
Harmonic coordinates, The Dirichlet problem, Laplace’s equation, Harmonic functions, External cone condition, Elliptic regularity theorem, Barrier function,
Barycentric coordinates, Generalized barycentric coordinates, Pixar, Cage, Affine
geometry.
Contents
2 Introduction, 5
3 Historic notes, 7
3.1 Pierre-Simon Laplace, 7
3.2 August Ferdinand Möbius, 8
3.3 Peter L. Dirichlet, 8
3.4 Erlanger Programm, 9
3.5 Pixar, 9
4 Preliminaries, 11
4.1 Interpolation, 11
4.2 Cage, 11
4.3 Affine geometry, 12
4.4 Partial differential equation, 12
4.5 Cone, 12
5 Barycentric coordinates, 13
5.1 Normalized barycentric coordinates – areal coordinates, 13
5.2 Ceva’s theorem, 15
5.3 Uniqueness of areal coordinates, 15
6 Key properties of barycentric coordinates, 17
6.1 Conservation of vertex coordinates, 17
6.2 Smoothness, 17
6.3 Affine invariance, 17
7 Generalized barycentric coordinates, 18
7.1 Binding, 18
7.2 Mean-value coordinates, 18
7.3 Pixar’s generalized barycentric coordinates: Harmonic coordinates, 18
8 Harmonic functions and properties, 19
8.1 Laplace’s equation & the Laplacian, 19
8.2 Harmonic functions, 19
8.3 Subharmonic functions, 19
8.4 Mean-value theorem for harmonic functions, 19
8.5 Maximum/minimum property for harmonic functions, 20
8.6 Uniqueness property for harmonic functions, 20
9 The Dirichlet problem, 21
9.1 Solvability of a Dirichlet problem with the Laplace’s equation, 21
9.2 Barrier function, 21
9.3 External cone condition, 22
9.4 Solvability of a bounded Dirichlet problem, 22
9.5 Elliptic regularity theorem, 22
10 Harmonic coordinates, 23
11 Key properties of harmonic coordinates, 25
11.1 Conservation of vertex coordinates, 25
11.2 Smoothness, 25
11.3 Affine invariance, 25
12 Example of harmonic coordinates, 27
12.1 Method of separation of variables, 28
12.2 The principle of superposition, 28
12.3 Solution of our example, 30
12.4 Alternative solution of our example, 31
12.5 Matlab code & plot of our example, 32
13 Final thoughts, 33
14 References, 34
15 Special thanks, 35
2 Introduction
August Möbius inadvertently constructed an ingenious way to linearly interpolate values given at the vertices of a triangle when he constructed a special kind
of coordinates in his groundbreaking work ”Der barycentrische Calcül, ein neues
Hülfs- mittel zur analytischen Behandlung der Geometrie”. These coordinates are
called Barycentric coordinates.
Barycentric coordinates can conceptually be thought of as weights, positioned on
the vertices of a massless solid triangle. These weights are then used to map points
contained inside and at the boundary of the triangle, by balancing the triangle
(with the different weights) on a fulcrum – a prop or support. The weights (i.e.
barycentric coordinates) thus act as control points for all points contained inside
and at the boundary of the triangle. The triangle that contains the points are called
a cage.
One of the key advantages of using barycentric coordinates compared with other
interpolation methods is the process called binding. Mathematically, binding is
simply the process of changing coordinate systems, from Cartesian coordinates to
Barycentric coordinates. Given the initial cage, each of it’s interior points need to
be computed, that is translated to the new coordinate system. The binding computation is normally computationally intense. However, after the binding process,
much less computation power is needed for calculating the new locations/values
of the interior points when the reference points are moved. This is because, after
the binding process, all interior points are expressed as linear combinations. Linear
combinations are, of course, calculated blazingly fast on a computer.
Because of barycentric coordinates’ great properties and applications, the problem
of generalizing them to work with different kinds of cages, i.e. polygons or polyhedrons instead of triangles or tetrahedrons, has been the subject of intense research
within the computer graphics community. The problem is surprisingly difficult.
The key issue that arises is when the cage is non-convex.
In 2003, Michael S. Floater introduced a generalization of barycentric coordinates
which he called mean-value coordinates. Mean-value coordinates are highly effective. However, they are only defined for cages that form star-shaped polygons or
polyhedrons. Floater’s article was the most cited article at ACM (Association for
Computing Machinery) 2003 and mark the starting point of an explosion of new
generalizations of barycentric coordinates.
5
The famous animation studio Pixar (behind critically acclaimed movies such as Toy
Story and Finding Nemo) introduced their generalization of barycentric coordinates at the annual graphic convention Siggraph in 2007. Pixar called their generalization harmonic coordinates. Pixar’s construction have all the great properties
of barycentric coordinates. They are also defined for cages formed by any arbitrary
non-convex and convex polygon or polyhedron. This is a significant improvement
compared to previous generalizations. Pixar developed and first used harmonic
coordinates to articulate their character Remy in their feature film Ratatouille.
Conceptually, harmonic coordinates can be thought of as a static gravitational or
electrostatic system, where each harmonic coordinate represents a potential – with
a gravitational or electrostatic pull. The equation used for describing these kind of
potential systems (and in turn harmonic coordinates) is Laplace’s classic partial differential equation.
Harmonic coordinates spring from the solutions of a specific boundary value problem. A boundary value problem is a differential equation fused together with a set
of constraints, called boundary conditions. Harmonic coordinates use the Laplace’s
equation as its core differential equation and a certain top-hat function for boundary conditions. Recall that the boundary is defined by the cage.
As with more or less all boundary value problems, harmonic coordinates lack a
closed formed expression and need to be computed using a brute force computational approach. This requires significant computational effort and is the major
drawback of harmonic coordinates – a distinct difference compared to barycentric
coordinates.
The aim of this paper is to explain barycentric and harmonic coordinates and to
put them in a proper mathematical context. This paper will provide proofs of the
key properties of barycentric and harmonic coordinates. This paper will also identify the key propositions from harmonic function theory used in the construction
of harmonic coordinates. Furthermore, this paper will show that harmonic coordinates are in fact the classic Dirichlet problem.
6
3 Historic notes
Harmonic coordinates were created by the famous movie production company
Pixar. The mathematical foundation of Pixar’s coordinates springs from the ideas
of some of the greatest mathematicians of all time. It is interesting and fruitful to
have some historical background about some of these key thinkers and of Pixar
itself.
3.1 Pierre-Simon Laplace (1749-1827)
Pierre-Simon Laplace was such a highly influential mathematician and theoretical
astronomer that he during his lifetime was known as the Newton of France [Simmons, page 171].
At the age of 20 he become professor of mathematics at the prestigious École
Militaire, where he later examined Napoleon Bonaparte. Napoleon later appointed
Laplace to the Senate.
Perhaps the most famous work of Laplace is his monumental treatise Mecanique
Céleste (published in five volumes from 1799 to 1825). In Mecanique Céleste,
Laplace masterfully summarized and expanded the work of gravitation by several famous and influential former mathematicians. Laplace does this without
acknowledging many of the ideas of others. However, he adds so much value that
his work still stands firm as a masterpiece. For example; a great challenge to the accuracy of Newton’s laws was the irregularities in the motion of Jupiter and Saturn,
something that Laplace solved in his work.
This statement stands in contrast to Newton’s view, who saw divine intervention
as the reason for everything disintegrating into chaos. Laplace saw the universe
itself as a fixed and dynamical system that would stay intact forever.
Laplace other great work was Théorie Analytic des Probabilities (1812) in which he
integrated and explained his own and others discoveries in the theory of probability. He again failed to acknowledge others contributions [Simmons, page 172].
But again, Laplace’s work is still considered as the greatest achievement ever by a
single person in the field of probability, perhaps even surpassing his former work
(Mecanique Céleste) [Simmons, page 172].
Laplace always had political aspirations and saw the value of applying probability
theory to the social field, especially in demography. He estimated at the time the
population of France to be around 25 millions. Among them, Laplace considered
himself to be number one [Grattan-Guinness].
7
3.2 August Ferdinand Möbius (1790-1868)
August Ferdinand Möbius (1790-1868) was a German mathematician and a theoretical astronomer. Among others he studied under Gauss.
Möbius’ geometry differs from classical Euclidian mathematics in that it does not
involve the measurement of distances. Therefore Möbius geometry can be described as a geometry of surfaces in an ambient space that contains a conformal
class of metrics but does not carry a specific metric. [Hertlich-Jewromin, page 1].
3.3 Peter L. Dirichlet (1805-1859)
Peter L Dirichlet was a German mathematician who succeeded Gauss as professor
of Göttingen in 1855. He interpreted and transmitted the knowledge of Gauss and
his works. Among other things, Dirichlet built on and developed Fourier’s theory
of trigonometric series [William, page 62].
Dirichlet was heavily influenced by Gauss great work Disquisitiones Arithmetique
(1801). Dirichlet was probably, at the time, one of the few people who understood
this great work – with its groundbreaking discoveries in number theory. Dirichlet
was almost obsessed by Disquisitiones Arithmetique and read it over and over
during of his life. In fact, it was always on his desk when he worked [Simmons,
page 192].
Dirichlet was also a friend of the great Riemann and helped him achieve an academic position [Simmons, page 200].
Perhaps Dirichlet’s greatest work was two long memoirs, published in 1837 and
in 1839. In the memoirs he made very remarkable applications of analysis to the
theory of numbers.
Dirichlet was also interested in mathematical physics. His most famous contribution in this field is called the Dirichlet principle of potential theory. It affirms the
existence of harmonic functions: Functions that satisfy Laplace’s equation with
prescribed boundary values. Riemann named the problem: the Dirichlet problem.
The principle/problem was an important foundation of Riemann’s work – and he
used it with great effect. In the beginning of the twentieth century Hilbert formulated a solid proof to the principle/problem [Simmons, page 192].
8
3.4 Erlanger Programm
Felix Klein put forward a groundbreaking way to unify and classify various geometrical studies in his famous Erlanger Programm. He stated this program at his
inaugural address of the University of Erlangen 1872 – a mile stone in the study of
geometry.
The Erlanger programm unified and classified various geometrical studies of the
nineteenth century. Klein viewed geometry as the study of those properties that
remain invariant under the action of a particular group of transformations. So, according to Klein, the criterion that distinguishes one geometry from another is the
group of transformations under which the propositions of that geometry remains
true.
Klein provided several examples of geometries and their associated groups. Ordinary Euclidean geometry in two dimensions corresponds to what Klein called the
“principal group”.
3.5 Pixar
The digital animation studio Pixar was established as an independent company
when Steve Jobs purchased a computer graphics division from Lucasfilm Ltd. At
the time (in 1986) Steve Jobs had just been kicked out of Apple and had no problem to pay the 10 million dollars required to buy the division from George Lucas.
The newly independent company included two founding members of the Lucasfilm Computer Division that Steve Jobs bought: Dr. Edwin Catmull and Dr. Alvy
Ray Smith. Both had a long history of inventions and work in the field of graphics
animation. The company also brought over John Lasseter. Steve Jobs gave Lasseter
the freedom to direct, produce, write, and create models for many of Pixar’s projects.
Jobs pushed for a new graphic interface called RenderMan. With RenderMan he
wanted to set an industry standard for 3D Graphics - in the same way that Adobe
had Postscript as the standard for desktop publishing. But due to technical restrictions at the time, business was slow. Jobs literally poured money into Pixar. ”If I
knew in 1986 how much it was going to cost to keep Pixar going, I doubt if I would
have bought the company” Jobs freely admitted [Linzmayer, page 221].
Before the breakthrough with Toy Story in 1995, Pixar made critically acclaimed
animated short films and groundbreaking commercials under the creative direction of John Lasseter.
9
The beginnings of Pixar was really slow - the computer power for digital animation
was extremely weak compared to now. It needed the inspired minds of Catmull,
Smith, Lasseter and the visionary mind of Jobs to get the company through the
troublesome beginnings.
In 2006, Disney officially acquired Pixar.
10
4 Preliminaries
4.1 Interpolation
The word interpolation stems from two latin words; inter and polire. Inter means
between and polire means to polish or make smooth.
In mathematics, interpolation generally denotes the technique of estimating new
data points, inside an interval or region, from values that are known. The function
that estimates these new values is called an interpolant. The interpolant needs to
be defined at all points inside the interval or region in question. The interpolant
also needs to reproduce our original data points. Naturally, we want the interpolant to approximate the new values inside the interval or region in the best possible manner.
A good interpolant strikes a good balance between speed of calculation, numerical
stableness and smoothness. These demands are not easy to satisfy at the same time.
For example, a high level of smoothness, normally requires a more computationally expensive interpolant.
4.2 Cage
In the field of computer graphics, the region or domain of the interpolant is normally called a cage. A cage is a geometric shape or volume that controls and encapsulates the points that we want to interpolate. In feature film production the
defining of a cage, i.e. its geometric structure, is an important part of character
articulation. This key component is usually called rigging. This is because the cage
is the controlling mechanism for the animator, analog to how a marionette is controlled from above using wires or strings.
In this paper the cage, denoted Ω, is a simple polygon or polyhedron according to
whether we work in two or three dimensions. A simple polygon or polyhedron is
not self-intersecting and is topologically equivalent to a disk or sphere. The faces of
a simple polyhedron are simple polygons. Because of this, the cage in this paper is a
closed set.
It is standard practice to triangulatized the cage, that is convert the faces of the cage
to triangles. Pixar defines their cage as ”any closed triangular surface mesh”.
However, the conversion of the faces of the cage is not necessary for the mathematical theory to hold – it just makes life easier. In this paper the cage Ω is assumed
to be triangulated, i.e. the cage is divided into triangles.
11
4.3 Affine geometry
Following Klein’s Erlanger programm: Affine geometry consists of the affine transformations that form a group. Affine transformations are all transformations of the
form:
T(x) = Ax + b, where A is a invertible 3x3 matrix and b ! R3
Affine transformations map straight lines to straight lines, map parallel lines to
parallel lines, and preserve ratios of lengths along a given line [Brannan, Esplen &
Gray, page 55]. This means that shapes and volumes that are scaled, rotated and/
or translated are congruent with each other – that is, identified as the same. In this
paper, this property is denoted as affine invariance.
It’s believed that Euler coined the word affine, which steams from the Latin word
affinis meaning related. This geometry became recognized as a self-contained discipline after the launching of Klein’s Erlanger programm [Coxeter, page 191].
4.4 Partial differential equation
A partial differential equation is an equation relating an unknown function, acting
as the dependent variable, of two or more variables to its partial derivaties with
respect to those variables. A very large part of mathematical physics is concerned
with partial differential equations. Usually, the independent variables describes
position and/or time.
Example:
2u + c 2u = 0 , where u(x,t) is function, is a partial differential equation.
2t
2x
In the example above, u(x,t) = ex−ct or u(x,t) = cos(x − ct) are solutions to the partial
differential equation.
4.5 Cone
A cone is a n-dimensional geometric shape that diminish smoothly from a base,
that is usually flat and circular, to a vertex point p. Formally, it is the solid figure
formed by the locus of all straight line segments that join vertex point p to the
base.
p
Base
12
5 Barycentric coordinates
August Möbius inadvertently constructed an ingenious way to linearly interpolate values given at the vertices of a triangle when he constructed a special kind
of coordinates in his groundbreaking work ”Der barycentrische Calcül, ein neues
Hülfs- mittel zur analytischen Behandlung der Geometrie”. These coordinates are
called barycentric coordinates.
Barycentric coordinates can conceptually be thought of as weights, positioned on
the vertices of a massless solid triangle. These weights are then used to map points
contained inside and at the boundary of the triangle, by balancing the triangle
(with the different weights) on a fulcrum – a prop or support. The weights (i.e.
barycentric coordinates) thus act as control points for all points contained inside
and at the boundary of the triangle. The triangle that contains the points are called
a cage.
5.1 Normalized barycentric coordinates – areal coordinates
Normalized barycentric coordinates in triangles are known as areal coordinates.
This is because normalized barycentric coordinates are the actual areas of the sub
triangles PAC, PAB and PBC normalized by the total area of triangle ABC. The
barycentric coordinate for the respective vertex correspond to the area of the sub
triangle formed on the opposite side of the vertex (divided by the total area of the
triangle).
C
wB
P = wAA + wBB + wCC
wA+wB+wC = 1
wA
p
A
wC
B
w A = area of BCP
area of ABC
w B = area of CAP
area of ABC
w C = area of ABP
area of ABC
13
Proof [Lidberg, page 12]
Suppose P = wAA + wBB + wCC, wA+wB+wC = 1 and 0 ≤ wA, wB, wC ≤ 1
A = (xA, yA), B = (xB, yB), C = (xC, yC), P = (xP, yP)
xP = wAxA + wBxB + wCxC
yP = wAyA + wByB + wCyC
x A yA 1
Area of ABC = 1 xB yB 1 = xA yB + xC yA + xB yC - xC yB - xA yC - xB yA
2
x C yC 1
x B yB 1
1
x y 1 = 1 [ x B yC + x P yB + x C yP - x P yC - x B yP - x C yB] =
Area of BCP =
2
2 C C
x P yP 1
1 [x y + (w x + w x + w x ) y + x (w y + w y + w y )
A A
B B
C C
B
C
A A
B B
C C
2 B C
- (w A xA + w B xB + w C xC) yC - xB (w A yA + w B yB + w C yC) - xC yB] =
1 [x y + w x y + w x y + w x y + w x y + w x y + w x y
A A B
B B B
C C B
A C A
B C B
C C C
2 B C
- w A x A yC - w B x B yC - w C x C yC - w A x B yA - w B x B yB - w C x B yC - x C yB ] =
1 [ x y - x y + w (x y + x y - x y - x y ) + w (x y - x y )
A
A B
C A
B A
A C
B
C B
B C
2 B C C B
+ w C (xC yB - xB yC)] =
x A yA 1
1 w [x y + x y + x y - x y - x y - x y ] = 1 w x y 1 =
B
A
A B
C A
B C
C B
A C
B A
A
B
2
2
x C yC 1
area
of
BCP
w A $ (area of ABC) * w A =
area of ABC
Similarly,
x C yC 1
x A yA 1
Area of CAP = 1 xA yA 1 = 1 w B xB yB 1 =
2
2
x P yP 1
x C yC 1
w B $ (area of CAP ) * w B = area of CAP
area of ABC
and
x A yA 1
x A yA 1
Area of ABP = 1 xB yB 1 = 1 w C xB yB 1 =
2
2
x P yP 1
x C yC 1
w C $ (area of ABC) * w C = area of ABP
area of ABC
14
5.2 Ceva’s theorem
THEOREM : The three lines AE, BF and CD, where E, F and D are points on the
opposite sides of facing vertices A, B and C in triangle ABC, are concurrent at point
P, if and only if:
C
AD BE CF
$
$
=1
DB EC FA
E
F
P
A
D
B
5.3 Uniqueness of areal coordinates
THEOREM: Areal coordinates define a unique point P inside or at the boundary of
an arbitrary triangle ABC
Proof [Lidberg, page 14]
This proof uses the fact that areas of triangles with equal altitudes are proportional
to the bases of the triangle. Using this fact and by referring to figure below, we get:
AD = CAD = PAD & CAD - PAD = CAP
DB
CDB
PDB
CDB - PDB
BCP
(5.3.1)
This is motivated by:
a = c = k & c = dk, a = bk
b d
a - c = bk - dk = k (b - d) = k = a
b-d
b-d
b-d
b
Similarly:
BE = AEB = BPE & AEB - BPE = ABP
EC AEC CPE
AEC - CPE CAP
CF FCB
FPC
FCB - FPC
BCP
FA = ABF = AFP & ABF - AFP = ABP
(5.3.2)
(5.3.3)
By multipling (5.3.1), (5.3.2) and (5.3.3) together we get:
AD BE CF
CAP ABP BCP
$
$
=
$
$
=1
DB EC FA
BCP CAP ABP
(5.3.4)
15
Note the following about (5.3.4):
(i) The internal triangles CAP, BCP, ABP are the areal coordinates for ABC.
(ii) The first part of the equation are the same ratios used in Ceva’s theorem (see
section 5.2), so they define a unique point P.
By combining our observations about (5.3.4), we have proved that areal coordinates define a unique point P. The point is inside or at the boundary of triangle
ABC because the areal coordinates’ sum (= the sum of the internal triangles’ CAP,
BCP and ABP areas) never can exceed the total area of ABC.
16
6 Key properties of barycentric coordinates
Barycentric coordinates possess a number of key properties that make them so
useful.
6.1 Conservation of vertex coordinates
Recall that normalized barycentric coordinates in two dimensions are constructed
using areas of triangles formed by the vertices, vi (i = 1, 2, 3), and the point p. Every
barycentric coordinate, wi, equals the area of the triangle formed by p and vertices
vj (i ≠ j, i, j = 1, 2, 3) normalized by the area of the cage. The area of the cage is the
area of the triangle formed by; vi, i = 1,2,3. In this way, the sum of all the weights
equals 1.
It follows from the construction that if a point p equals one of the three vertices
then p equals one of the following unit vector: w1 = (1,0,0), w2 = (0,1,0) and w3 =
(0,0,1) in this barycentric coordinate system.
6.2 Smoothness
As the determinant function, that is used for calculating the areas that represent
the barycentric coordinates, is a C∞ function, it follows that the barycentric coordinates are smooth.
6.3 Affine invariance
Again, barycentric coordinates are represented by areas of triangle, normalized by
the cage’s area. The area are the same regardless of translation and/or rotation. As
barycentric coordinates are always normalized by the cage’s area, barycentric coordinates are the same regardless of scaling.
17
7 Generalized barycentric coordinates
Because of barycentric coordinates’ great properties and applications, the problem
of generalizing them to work with different kinds of cages, i.e. polygons or polyhedrons instead of triangles or tetrahedrons, has been the subject of intense research
within the computer graphics community. The coordinates are often denoted with
the family name: Generalized barycentric coordinates.
7.1 Binding
One of the key advantages of using barycentric coordinates compared with other
interpolation methods is the process called binding. Mathematically, binding is
simply the process of changing coordinate systems – from Cartesian coordinates
to barycentric coordinates. Given the initial cage, each of its interior points need to
be computed, that is translated to the new coordinate system. The binding computation is normally computationally intense. However, after the binding process,
much less computation power is needed for calculating the new locations/values
of the interior points when the reference points are moved. This is because, after
the binding process, all interior points are expressed as linear combinations. Linear
combinations are, of course, calculated blazingly fast on a computer.
The problem of generalizing barycentric coordinates, while keeping the binding
aspect and interpolation properties intact, is surprisingly difficult. The key issue
that arises is when the cage is non-convex.
7.2 Mean-value coordinates
In 2003, Michael S. Floater introduced a generalization of barycentric coordinates
which he called mean-value coordinates. Mean-value coordinates are highly effective and have the same binding process as classic barycentric coordinates. However, they are only defined for cages that form star-shaped polygons or polyhedrons.
Floater’s article was the most cited article at ACM (Association for Computing
Machinery) 2003 and mark the starting point of an explosion of new generalizations of barycentric coordinates.
7.3 Pixar’s generalized barycentric coordinates: Harmonic coordinates
The famous animation studio Pixar introduced their generalization of barycentric
coordinates at the annual graphic convention Siggraph in 2007. Pixar called their
generalization for harmonic coordinates. Pixar’s construction have all the great
properties of barycentric coordinates and also keep the binding process. They
are also defined for cages formed by any arbitrary non-convex or convex simple
polygons or polyhedrons. This is a significant improvement compared to previous
generalizations. Pixar developed and used harmonic coordinates to articulate their
character Remy in their feature film Ratatouille.
18
8 Harmonic functions and their properties
Before we jump in and start explaining and constructing harmonic coordinates,
there is a number of preliminaries and theorems that we need to cover.
8.1 Laplace’s equation & Laplacian
Perhaps the most famous and used partial differential equation is Laplace’s equation. In three dimensions, it is written as:
2
2
2
Ou = 2 u2 + 2 u2 + 2 u2 = 0
2x
2y
2z
The operator ∆ is called the Laplacian. The Laplacian is a linear operator, i.e:
O (af + bg) = aOf + bOg , where f, g are functions and a, b are scalars.
8.2 Harmonic functions
A twice continuously differentiable (C2) function u is called a harmonic function, if
it is a solution to Laplace’s equation on a certain open subset Ω of Rn.
8.3 Subharmonic functions
A continuos function (C0) u in the cage Ω is called subharmonic, if for every closed
ball inside the interior of cage and every continuous function h on the closed ball
where h is harmonic on the interior of the ball where we have u ≤ h on the boundary of the ball then u ≤ h also on the interior of the ball [Renardy & Rogers, page
113].
8.4 Mean-value theorem for harmonic functions
Harmonic functions have two key properties which are essential for constructing harmonic coordinates. Both properties follow from the mean-value theorem,
which informally states that the value of a harmonic function at any point is equal
to the average of its values around any circle or ball centered at that point.
THEOREM [Kozlov, Maz’ya & Rossmann, page 14]: Let u be a harmonic function
in the cage Ω, then for any ball B with center a and radius r, contained in the
interior of Ω, we have
1
u (a) = 2π r # u $ ds in two dimensions
2B
1 #
u (a) =
u $ ds in three dimensions
4π r2 2B
where 2B denotes the boundary of the ball B and
ds denotes the surface element in the integral.
19
8.5 Maximum/minimum property for harmonic functions
THEOREM [Axler, Bourdon & Ramey, page 7]: Let Ω be a bounded domain for a
continuous real-valued function u. If u is harmonic on the interior of Ω, then u attains its maximum and minimum values (over the interior of Ω) on the boundary
of Ω.
Informally, the largest and smallest value that a harmonic function attains on a
region is found on the boundary of that region.
8.6 Uniqueness property for harmonic functions
CORROLLARY [Axler, Bourdon & Ramey, page 7]: It follows from the max/min
property that if we know the values of the function along the boundary of a region,
then there is only one harmonic function defined in that region with those specific
boundary values. .
Proof:
Assume that f and g are solutions to the Laplace’s equation with the same boundary conditions.
By linearity (see section 8.1): ∆(f - g) = 0 and f - g = 0 on boundary of Ω.
By using the maximum/minimum property for harmonic functions (see section
8.5), we get f - g = 0 on the entire Ω. Hence f = g.
20
9 The Dirichlet problem
A Dirichlet problem is the problem of finding a function which solves a specified
partial differential equation in the interior of a given region and that takes prescribed values on the boundary of the region. In essence, a Dirichlet problem is a
boundary value problem with a partial differential equation at its core.
Laplace’s equation is what is used in this paper and for the construction of Harmonic coordinates. This is because we are interested in decribing mathematically a
potential. In fact, the Dirichlet problem was originally posed for Laplace’s equation
and is sometimes referred to as “the first boundary value problem of the potential
theory” [Axler, Bourdon & Ramey, page 223]. However, the Dirichlet problem
can be solved for many different partial differential equations.
As solutions for the Laplace’s equation are harmonic functions, our Dirichlet problem can be reformulated to better suite our needs:
Given a function f that has values everywhere on the boundary of a region in Rn, is
there a unique continuous function u twice continuously differentiable in the interior
and continuous on the boundary, such that u is harmonic in the interior and u = f on
the boundary?
The requirement, u = f on the boundary, is called the Dirichlet boundary condition.
9.1 Solvability of a Dirichlet problem with the Laplace’s equation
Although, the existence of a unique solution to the Dirichlet problem with the
Laplace’ equation is very plausible by the ‘physical argument’, the mathematical
solution is difficult to find and the search for a solution has led much of the development of harmonic function theory.
9.2 Barrier function
One way to answer the question of solvability of the Dirichlet problem is to use a
barrier function. Barrier functions were introduced by Poincaré to aid the study of
the Dirichlet problem [Axler, Bourdon & Ramey, page 227]. It provides us with
some very useful theorems. A barrier function is defined in the following way:
Let a point p belong to the boundary of Ω. We call a continuous real-valued function u on Ω a barrier function at p provided that u is subharmonic on Ω, u < 0 on
Ω = " p , and u(p) = 0.
21
9.3 External cone condition
THEOREM [Axler, Bourdon & Ramey, page 232]: If Ω is bounded and p belongs
to the boundary of Ω and there exists a cone with p as its vertex and the cone (see
section 4.5) is contained in the complement of Ω (with the exception of p), then Ω
has a barrier at p.
9.4 Solvability of a bounded Dirichlet problem
THEOREM [Axler, Bourdon & Ramey, page 228]: The Dirichlet problem for
bounded Ω is solvable if and only if Ω has a barrier at each p on the boundary of Ω.
TO SUMMARIZE: If Ω is a simple polyhedron then there exists an external cone
for each point on the boundary of Ω, hence the Dirichlet problem is solvable for
simple polyhedrons.
9.5 Elliptic regularity theorem
THEOREM [Evans, page 28]: A harmonic function h is smooth (C∞) on the interior of Ω if:
(i) h is locally integrable on the interior of Ω. A function is called locally integrable
if, around every point in the domain, there is a neighborhood on which the function is integrable [http://mathworld.wolfram.com/LocallyIntegrable.html].
(ii) h is twice continuously differentiable on the interior of Ω, h d C2(int(Ω)).
(iii) h is continous on the boundary of Ω, h d C0( 2 Ω).
22
10 Harmonic coordinates
Now, with all mathematical bits and pieces defined and explained, the construction of harmonic coordinates are quite straight forward:
(1) Consider a cage, Ω, with n number of vertices vi.
(2) Consider the edges between neighbouring vertices vi:
Define functions φi(p), where i=1,...,n, on the edges of the cage with the following
interpolation property:
φ
φφi(vj) = 1 when i = j
φφi(vj) = 0 when i ≠ j
φφi(p) is linear on each edge of the cage
In this way, φi(p) are piecewise linear
functions on the edges of the cage (see figure).
1
vj
vk
p
vi
If the cage is in three dimensions, then we need to extend φi(p) on the faces of
the cage using barycentric coordinates in two dimensions. Recall that our cage is
triangulated (see section 4.2), so we can easily use barycentric coordinates in two
dimensions for this extension. But this extension can, of course, be done in other
ways.
(3) Define a classical Dirichlet problem for the cage Ω with the boundary conditions defined in (2). Hence, we are searching for solutions in the form of a set of
harmonic functions hi(p) that satisfy Laplace’s equation on the interior of the cage
Ω in the following way:
hi(p) → φi(po) as p → po
where po is at the boundary of Ω and p is in the interior of Ω and
p, po are given by Cartesian coordinates in two or three dimensions.
We know from the external cone condition theorem (see section 9.3) that the
Dirichlet problem for simple polyhedrons is solvable, hence the set of harmonic
functions hi(p) exists for this construction.
23
(4) The Cartesian coordinate of the point p in the interior of the cage Ω can now
be calculated by:
n
p = / h i (p) vi
i =1
Proof of (4):
(i) Define a function g as the following:
n
J
N
Kp x - / h i (p) vi,xO J
i=1
K
O Kg x (p)NO
n
n
g (p) = p - / h i (p) vi = Kp y - / h i (p) vi,yO = Kg y (p)O
K
O K
O
i=1
i=1
n
K
O Lg z (p)P
Kp z - / h i (p) vi,yO
i=1
L
P
n
J
N
Kp x - / { i (p) vi,xO J
i =1
K
O Kg x (p)NO
n
n
g (p) = p - / { i (p) vi = Kp y - / { i (p) vi,yO = Kg y (p)O
K
O K
O
i=1
i =1
n
K
O Lg z (p)P
Kp z - / { i (p) vi,z O
i=1
L
P
on int(Ω).
on ∂Ω.
Note the vector notation above.
(ii) g(p) = 0 on all vertex points, vi, since
φi(vj) = 1 when i = j
φi(vj) = 0 when i ≠ j
(iii) Each gx(p), gy(p) and gz(p) is a harmonic function on the interior of the cage,
due to the fact that harmonic functions are closed under linear combinations [Axler, Bourdon & Ramey, page 2].
(iv) Consider the edge between two neighboring vertices and suppose p lies on
this edge. Since φi equals 1 or 0 at the vertices and φi is linear along the edges and
there can only exist one line between to two points, g(p) must equal 0 on the
edges.
(v) Now, consider when p lies on a face of the cage. Recall, that our cage is triangulated (see section 4.2), so a face equals a triangle. Using the uniqueness property of
barycentric coordinates g(p) = 0 (see section 8.6).
(vi) Again using the uniqueness property for harmonic functions (see section 8.6),
hi(p) inside the cage is uniquely defined by the boundary conditions. As g(p) = 0 on
the boundary of the cage, g(p) inside the cage must also equal 0.
24
11 Key properties of harmonic coordinates
Harmonic coordinates possess the same key properties as barycentric coordinates.
11.1 Conservation of vertex coordinates
By construction, each vertex of the cage gets its harmonic coordinate set to 1:
h i (v j ) = d i , j
1 if i = j
d i,j = )
0 if i ≠ j
Consider the case h i (p) = d i,j where p = vj then
n
n
i=1
i=1
p = / h i (p) vi = / d i,j vi = vj
11.2 Smoothness
By Elliptic regularity theorem (see section 9.5): hi is smooth ( C 3 ) on the interior
of the cage.
11.3 Affine invariance
Affine invariance means that harmonic coordinates are the same, regardless if the
cage, Ω, is scaled, translated or rotated (see section 4.3).
Proof:
Let T(Ω) be any affine transformation of the cage Ω.
Recall that T is bijective, so if p' d T(Ω) then p' = T(p) for some p d Ω.
For clarity, we use the notion h v for h i .
i
t v (p') = h v (T -1 (p')) on T(Ω) Define h
(11.3.1)
ht v solves Laplace’s equation on T(Ω) with the same boundary conditions as h T (v ) .
i
i
i
i
T
p
p
T -1
25
Because of the uniqueness property for harmonic functions (see section 8.6):
ht v (p') = h T (v ) (p') for all p' d T(Ω) (11.3.2)
i
i
By combining (11.3.1), (11.3.2) and the fact that T is bijective we get the following:
ht v (p') = h v (T -1 (p')) = h v (p)(11.3.3)
h T (v ) (p') = h T (v ) (T (p)) (11.3.4)
i
i
i
i
i
Finally by combining (11.3.2), (11.3.3) and (11.3.4), we get:
h v (p) = h T (v ) (T (p))
i
i
26
12 Example of harmonic coordinates
It is easier to understand the construction of harmonic coordinates with an
example. This example will be provided in two dimensions.
Consider a cage Ω defined in the figure below:
y
π
v4
v3
p
v2
v1
0
2π
x
Now, we want calculate the harmonic coordinates hi(x,y) for all points inside the
cage Ω. We do this, by defining a classical Dirichlet problem for the cage Ω with the
following boundary conditions on Ω:
x
{ 1 (x, y) = 1 - 2π on v1 " v2
y
{ 1 (x, y) = 1 - π on v4 " v1
{ 1 (x, y) = 0 on the two other edges
x
{ 2 (x, y) = 2π on v2 " v1
y
{ 2 (x, y) = 1 - π on v2 " v3
{ 2 (x, y) = 0 on the two other edges
x
{ 3 (x, y) = 2π on v3 " v2
y
{ 3 (x, y) = π on v3 " v4
{ 3 (x, y) = 0 on the two other edges
x
{ 4 (x, y) = 1 - 2π on v4 " v3
y
{ 4 (x, y) = π on v4 " v1
{ 4 (x, y) = 0 on the two other edges
27
12.1 Method of separation of variables
Consider a partial diffential equation with a solution h(x,y). Assume that there exists a solution on the form h(x,y) = X(x)Y(y).
Substituing this expression into Laplace’s equation:
2 2 h (x, y) 2 2 h (x, y) 2 2 (X (x) Y (y)) 2 2 (X (x) Y (y))
=
+
=
+
2x 2
2y 2
2x 2
2y 2
Xm (x) Y (y) + X (x) Ym (y) = 0
Now, let’s separate the variables x and y:
Ym (y)
Xm (x)
=X (x)
Y (y)
The left hand side is only dependent on x and the right hand side is only dependent of y. Hence both sides are constant with a value that can be denoted m 2 .
Now, consider the two ordinary differential equations:
(
Xm (x) - m 2 X (x) = 0
Ym (y) + m 2 Y (y) = 0
They have the following solutions [Renardy & Rogers, page 16]:
)
X (x) = A cosh mx + B sinh mx
Y (y) = C cos my + D sin my
where cosh and sinh are the corresponding eigenfunctions for X(x),
cos and sin are the corresponding eigenfunctions for Y(y),
m are the corresponding eigenvalue for both X(x) and Y(y).
To summarize h(x,y) can be expressed as:
h (x, y) = (A cosh mx + B sinh mx) $ (C cos my + D sin my)
12.2 The principle of superposition
Our Dirichlet problem has a linear partial differential equation, so mathematically
acceptable solutions can be formed by superposing solutions (i.e. adding) corresponding to different allowed values of the separation constants. In other words,
we can suppose that the required solution u(x,y) is made up of two parts [Riley,
Hobson & Bence, page 655]:
h(x,y) = f(x,y) + g(x,y) where f(x,y) and g(x,y) are the solutions satisfying the
boundary conditions shown in figure on the next page.
28
y
0
a1(x,y)
f1(x,y)
0
+
x
0
y
0
0
g1(x,y)
0
x
b1(x,y)
y
v4
=
a1(x,y)
0
v3
0
h1(x,y)
v2
v1
x
b1(x,y)
29
12.3 Solution of our example
Consider { 1 , let { 1 = a1(x,y) + b1(x,y) where:
y
a1 (x, y) = 1 - π on v1 " v4
a1 (x, y) = 0 on v2 " v3 , v3 " v4 and v1 " v2
x
b 1 (x, y) = 1 - 2π on v1 " v2
b 1 (x, y) = 0 on v2 " v3 , v3 " v4 and v4 " v1
Let’s solve f1(x,y) with boundary condition a1(x,y) by using the method of separation of variables. We look for solutions to the partial differential equation on the
form: (A cosh mx + B sinh mx) $ (C cos my + D sin my).
There are no constants A, B, C, D, m such that the boundary conditions holds.
However, we can make a sum of solutions on this form (using the principle of
superposition) such that:
f1 (x, y) =
3
/ (A
n
cosh m n x + B n sinh m n x) $ (C n cos m n y + D n sin m n y)
n=1
This is also a solution to Laplace’s equation and we can find:
{A n, B n, C n, D n, m n}, n = 1, ..., 3 }n, such that the boundary condition holds.
By rotating and translating the cage, we can subsititute x with (2π-x) and
reformulate f1(x,y) as:
f1 (x, y) =
3
/ (A
n
cosh m n (2π - x) + B n sinh m n (2π - x)) $ (C n cos m n y + D n sin m n y)
n=1
We only consider positive integers for m = 1, 2, 3, ...
f1(x,0) = 0 = f1(x,π) gives that C = 0
Since, f1(2π,y) = 0 then An = 0.
3
f (x, y) = / (B
1
n
sinh (n (2π - x))) $ (D n sin (ny))
n=1
Merge the two constants Bn and Dn to B1,n
f1 (x, y) =
3
/ (B
1,n
sinh (n (2π - x))) $ sin (ny)
n=1
30
Consider the boundary condition a1(0,y) as a Fourier sinus series expression.
Then B 1,n sinh (n (2π - x)) is the Fourier coefficient and hence can be calculated by
the following expression:
π
y
nπ y
2
#
B 1,n =
sin
1
(
)
(
π
π ) dy =
nπ 2π
π sinh ( π ) 0
π
y
2
#
(1 - π ) sin (ny) dy =
π sinh (n2π ) 0
2 (nπ - sin (nπ ))
2
=
π 2 sinh (2nπ ) n 2
π n sinh (2nπ )
By symmetry g1(x,y) must be of the same form with the difference that we translate with π and interchange of x and y.
We get the following expression for b1(x,y):
b 1 (x, y) =
3
/C
n=1
1, n
sinh (
n (π - y)
nx
) sin ( 2 )
2
2π
x
nπ x
2
C 1,n =
nππ # (1 - 2π ) sin ( 2π ) dx =
2π sinh ( 2π ) 0
2 (nπ - sin (nπ ))
2
=
1
1
2 2
π n sinh ( 2 nπ )
π n sinh ( 2 nπ )
Finally, h1(x,y) = a1(x,y) + b1(x,y).
12.4 Alternative solution of our example
In this particular example hi(x,y) correspond to the products of the line equations
for the cage:
hi(x,y) = ai(x,y)bi(x,y)
31
12.5 Matlab code & plot of our example
Now let’s calculate hi(x,y) = ai(x,y) + bi(x,y) using MatLab:
clc;
x=linspace(0,2*pi,200); %x
y=linspace(0,pi,200); %y
h1=zeros(200);
h2=zeros(200);
h3=zeros(200);
h4=zeros(200);
for i=1:200
for j=1:200
for n=1:50
B1 = 2/(n*pi*sinh(2*n*pi));
D1 = 2/(n*pi*sinh(0.5*n*pi));
B2 = 2/(n*pi*sinh(2*n*pi));
D2 = -2*(-1)^n/(n*pi*sinh(0.5*n*pi));
B3 = -2*(-1)^n/(n*pi*sinh(2*n*pi));
D3 = -2*(-1)^n/(n*pi*sinh(0.5*n*pi));
B4 = -2*(-1)^n/(n*pi*sinh(2*n*pi));
D4 = 2/(n*pi*sinh(0.5*n*pi));
h1(i,j) = h1(i,j) + B1*sinh(n*(2*pi-x(i)))
D1*sinh((n*(pi-y(j)))/2)
*sin((n*x(i))/2);
h2(i,j) = h2(i,j) + B2*sinh(n*(x(i)))
D2*sinh((n*(pi-y(j)))/2)
*sin((n*x(i))/2);
h3(i,j) = h3(i,j) + B3*sinh(n*(x(i)))
D3*sinh((n*(y(j)))/2)
*sin((n*x(i))/2);
h4(i,j) = h4(i,j) + B4*sinh(n*(2*pi-x(i)))
D4*sinh((n*(y(j)))/2)
*sin((n*x(i))/2);
*sin(n*y(j)) +
*sin(n*y(j)) +
*sin(n*y(j)) +
*sin(n*y(j)) +
end
end
end
Here is the result in the form of a contour plot from Matlab:
32
13 Final thoughts
Barycentric and generalized barycentric coordinates have three key advantages
over other interpolation methods; the use of a cage, the binding process and the
affine invariance property. These three advantages are perhaps best illustrated by
following Pixar’s use of harmonic coordinates for character articulation.
Firstly, as the character normally consists of millions of points, the character needs
to be rigged in such a way that the animator can move a smaller number of reference points to control the character. This problem is solved by the use of the cage.
Recall that the cage’s vertices completely control every point inside the cage. The
character, consisting of points inside the cage, can be seen as a modern form of
Pinocchio – that is a classical doll on a string.
Secondly, the animator needs to be able to animate the character in real-time. This
part of the problem is solved by the construction of harmonic coordinates. Recall
that the binding process, the change of coordinate systems, does the heavy lifting
when it comes to computation. After the binding process is done, much less computation power is needed for calculating the new locations/values of the interior
points when the reference points are moved.
Thirdly, the character (together with its cage) needs to be contained within itself.
So that it can be moved, rotated and scaled independently of the surrounding
Euclidean space. The affine invariance property of harmonic coordinates gives the
animator that freedom.
The underlying theory of harmonic coordinates are linked to the long development of analysis and theoretical physics during the nineteenth century. The ideas
feature some of the greatest mathematicians of all time. I think that many of the
ideas can be used to evolve harmonic coordinates even further. In particular,
the computation and implementation of harmonic coordinates could be greatly
improved by approximating initial values. Recall that harmonic coordinates lack a
closed formed expression and need to be computed using a brute force computational approach. This requires a significant computational effort and is the major
drawback of harmonic coordinates. So this is an aspect of harmonic coordinates
where further work would be fruitful.
I hope this paper have explained barycentric and harmonic coordinates in a good
way.
33
14 References
Axler S., Bourdon P., Ramey W., Harmonic Function Theory, Springer, Second
edition 2001.
Brannan, David A, Esplen Matthew F & Gray, Jeremy J. Geometry, Cambridge
University Press, 2004.
Coxeter, H.S.M., Introduction to Geometry, John Wiley & Sons, Inc, Second
edition 1989.
Evans, C. Lawrence, Partial Differential Equations, American Mathematical
Society, Second edition 2010.
Grattan-Guinness, Ivor, Mathematical sciences, Fontana Press, 1998.
Hertrich-Jeromin U., Introduction to Möbius Differential Geometry, Cambridge
University Press, 2003.
Karush, W., Matematisk uppslagsbok, Walhström & Widstrand, 1962.
Kozlov, V.A., Maz’ya, V.G., Rossman, J., Ellipic Boundary Value Problems in Domains with Point Singularities, American Mathematical Society, 1997.
Lidberg, P., Barycentric and Wachspress coordinates in two dimensions: theory and
implementation for shape transformations, Uppsala University, 2011.
Linzmayer, W. Owen, Apple Confidential 2.0, No Starch Press , 2004.
Renardy M., Rogers C. R., An Introduction to Partial Differential Equations,
Springer, 1993.
Riley, K.F., Hobson M.P., Bence S.J., Mathematical Methods For Physics And
Engineering, Cambridge University Press, Second edition 2002.
Simmons, George F, Calculus Gems - Brief Life and Memorable Mathematics,
McGraw-Hill, 2007.
34
15 Special thanks
Magnus Marin
Gustaf Halldin
35
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement