Shapes & spaces

Mean value cage deformation calculator for planar control polygons

Compute polygonal generalized barycentric coordinates for query points, then move them with a user-edited cage.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Compute polygonal generalized barycentric coordinates for query points, then move them with a user-edited cage. Unlike ARAP, this needs no triangle mesh or iterative rigidity energy.

THE FORMULAw_i=(tan(alpha_(i-1)/2)+tan(alpha_i/2))/||v_i-p||; lambda_i=w_i/Σw_j; p_new=Σlambda_i v_i_new.

A worked example

Use the square (0,0),(2,0),(2,2),(0,2) and its center (1,1). All four weights are 1/4. Moving the right edge to x=4 maps that center to (2,1).

Good to know

Simple source and target cages with matching 3–40 ordered vertices; at most 100 query points inside/on source cage; bounded coordinates. Target may become concave; reject self-intersection; do not guarantee interior injectivity.

Describe the same cage before and after editing

The source polygon defines the coordinate system used to locate sample points. The target polygon supplies the edited positions of those same control vertices. Match their row order exactly: source row three and target row three must describe the same control vertex.

The source polygon must be simple, with no crossing boundary edges. A cage is a closed boundary, so the last vertex connects back to the first automatically. Repeating the first vertex at the end creates a zero-length edge and should be removed.

A square-center query has four equal weightssource center (1,1)edited center (2,1)
Scroll across to see the full diagram.
A square-center query has four equal weights. Stretching the source cage horizontally carries its center to the target cage center.

Compare this with the As rigid as possible triangle mesh deformation calculator from handle targets. Compute polygonal generalized barycentric coordinates for query points, then move them with a user-edited cage. Unlike ARAP, this needs no triangle mesh or iterative rigidity energy.

Generalize triangle barycentric coordinates

A point inside a triangle can be written as a weighted sum of its three vertices. Mean value coordinates extend that idea to a polygon with more than three corners. The weights add to one and reproduce the original point in the source cage.

For a polygon, many weight vectors could reproduce one point. The mean value construction chooses a particular geometric rule based on adjacent viewing angles and distances. These weights are determined by the source cage and query point before the target cage is considered.

Use signed angles for concave cages

At a query point, vectors to two adjacent cage vertices form an oriented angle. Its signed half-angle tangent enters the two neighboring vertex weights. Replacing every signed angle by an absolute angle changes the construction for a concave cage.

Convex cages have positive interior weights. In a concave cage, negative weights may be mathematically valid and should not be silently clamped to zero. Clamping breaks the reconstruction and affine-precision identities on which the deformation depends.

Handle boundary points by their limiting coordinates

A point exactly at a cage vertex has weight one on that vertex and zero elsewhere. A point on a cage edge uses ordinary linear interpolation between the edge endpoints. These cases avoid dividing by a zero distance or evaluating an unstable half-angle formula.

Near a boundary, finite precision can make a theoretically well-defined formula difficult to evaluate. A consistent geometric tolerance should distinguish resolved edge membership from an unresolved near-singularity. A failed denominator check should be reported instead of manufacturing a plausible-looking point.

Apply fixed weights to the edited cage

Once the source weights have been computed, the target position is their weighted sum of the edited vertices. The square-center example makes this concrete: the average of the stretched cage corners is (2,1), so the center follows the cage edit.

An affine edit of the whole cage reproduces that same affine edit of every query point. Translation, rotation, shear and uniform or nonuniform scale therefore provide useful reference cases. A general free-form edit is not constrained to be affine.

Separate coordinate precision from shape guarantees

A small reconstruction residual confirms that the weights reproduce the source query and sum to one numerically. It does not measure angular distortion or the area change caused by the edit. Mean value deformation optimizes neither of those quantities.

Even when the target boundary remains simple, the interior map is not automatically guaranteed to be one-to-one for all concave configurations. Points can cluster or fold. Inspecting several sample points helps explain an edit, but it is not a global injectivity certificate. The source and target must keep corresponding vertex order; an arbitrary target reordering changes which cage vertex controls which weight. The code validates polygon simplicity while retaining entered correspondence. At a source vertex its weight is exactly one, and on an edge the two endpoint weights reduce to linear interpolation. These boundary limits avoid a division by zero in the general half-angle formula. Concave cages may produce negative weights, which should not be clamped: clamping would lose affine reconstruction and can change the mapped point. A simple target boundary still does not prove the entire interior mapping is injective.

Interpret interpolation and extrapolation limits

The initial scope accepts points inside or on the source cage. This keeps the interaction focused on deforming an enclosed object. Boundary points stay on their corresponding target edge because their two endpoint weights vary linearly.

The method uses no triangle connectivity and no iterative rigidity solver. If a task requires local stiffness, mesh-dependent constraints or guaranteed distortion bounds, those are additional modeling requirements. Adding more cage vertices changes the coordinate construction as well as the editing controls.

A few questions, answered

Are weights always positive?

They are positive inside a convex cage. Concave cages can produce valid negative weights; retaining the signs is necessary for the stated coordinate identities.

Does this preserve area or angles?

No. It reproduces affine transformations exactly, but arbitrary cage edits need not preserve lengths, area or angles.

What happens to a point on an edge?

It uses linear interpolation between that edge’s two control vertices. A vertex query follows the corresponding target vertex exactly.

Can the edited cage fold the interior?

Yes, some edits can fold or concentrate the interior. A simple target boundary and small reconstruction residual do not by themselves certify a one-to-one interior map.

Find your calculator

Start typing to explore the library.