fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
Polar and Spherical Domains

Fitting on non-rectangular domains—disc-shaped regions in the plane and the surface of a sphere—requires coordinate transformations that map the physical domain to a rectangular parameter space where tensor-product B-splines can be applied. These transformations introduce singularities (the origin of a disc, the poles of a sphere) where special continuity conditions must be imposed on the B-spline coefficients to ensure a smooth, single-valued result.

The presentation follows Dierckx (1993), Chapter 11.

Polar Coordinates

The polar domain

A general polar domain is the set of points \( (x, y) \) satisfying \( x^2 + y^2 \leq R(\theta)^2 \), where \( R(\theta) \) is a positive boundary function and \( \theta = \mathrm{atan2}(y, x) \). When \( R(\theta) \) is constant the domain is a circular disc.

Normalized polar transform

FITPACK maps the physical coordinates \( (x, y) \) to normalized polar coordinates \( (u, v) \) via

\[ x = u \, R(v) \cos v, \qquad y = u \, R(v) \sin v \]

with \( u \in [0, 1] \) and \( v \in [-\pi, \pi] \). The radial variable \( u \) runs from 0 (the origin) to 1 (the boundary), and \( v \) is the polar angle. In this parameter space the fitting problem becomes rectangular: find a tensor-product B-spline

\[ s(u, v) = \sum_{i} \sum_{j} c_{ij} \, N_{i,k}(u) \, M_{j,k}(v) \]

that approximates the data in a weighted least-squares sense, subject to a smoothing condition or prescribed knot placement.

FITPACK routines

Routine Input Boundary
polar (scattered) Arbitrary \( (x_i, y_i, z_i) \) General \( R(\theta) \) via function pointer
pogrid (gridded) Data on a polar grid \( (u_i, v_j) \) Constant radius \( R \)

Continuity at the Origin

The problem

At \( u = 0 \) all values of the angle \( v \) map to the same physical point—the origin. A naive tensor-product spline in \( (u, v) \) would assign potentially different values to \( s(0, v) \) for different \( v \), producing a discontinuous or non-smooth surface at the centre of the disc.

Continuity orders

To obtain a physically meaningful result the B-spline coefficients near \( u = 0 \) must satisfy algebraic constraints that enforce continuity to the desired order.

** \( C^0 \) continuity.** The function value at the origin must be single-valued:

\[ s(0, v) = c_0 \quad \text{(constant for all } v\text{)} \]

This is achieved by constraining all coefficients associated with the first radial B-spline to be equal.

** \( C^1 \) continuity.** In addition to \( C^0 \), the first radial derivative \( \partial s / \partial u \) at \( u = 0 \) must be consistent with a well-defined gradient vector in the \( (x, y) \) plane. Without this constraint, the directional derivative at the origin could depend on the approach angle in an unphysical way. The constraint takes the form of a linear relation among the coefficients of the first two radial B-splines.

** \( C^2 \) continuity.** The second radial derivatives must likewise be consistent with a well-defined Hessian at the origin. This imposes additional linear relations on the first three rows of coefficients.

Implementation in FITPACK

The bc_continuity_origin parameter selects the continuity order:

bc_continuity_origin Continuity Available for
0 \( C^0 \) Scattered and gridded polar
1 \( C^1 \) Scattered and gridded polar
2 \( C^2 \) (default) Scattered polar only

The constraints are incorporated into the least-squares system during fitting, reducing the effective number of free coefficients near \( u = 0 \).

Boundary Conditions on the Disc Edge

At the outer boundary \( u = 1 \) the following options are available:

  • Extrapolation (default): No constraint is imposed at the boundary. The spline is free to take any value at \( u = 1 \).
  • Zero boundary: The spline is forced to vanish on the boundary, \( s(1, v) = 0 \) for all \( v \). This is useful for problems where the function is known to be zero at the edge of the disc.

For gridded polar fitting (pogrid), additional options control the behaviour at the origin:

  • Prescribed origin value: The value \( z_0 = s(0, v) \) can be supplied explicitly. It can be enforced exactly (z0_exact = .true.) or treated as an additional data point to be approximated.
  • Zero gradient at the origin: Setting z0_zero_gradient = .true. enforces \( \nabla s(0, 0) = 0 \), creating a flat spot at the centre of the disc.

Spherical Coordinates

The spherical domain

The unit sphere is parameterized by colatitude \( \theta \in [0, \pi] \) and longitude \( \phi \in [0, 2\pi] \). A scalar function on the sphere is represented as a tensor-product B-spline:

\[ s(\theta, \phi) = \sum_{i} \sum_{j} c_{ij} \, N_{i,k}(\theta) \, M_{j,k}(\phi) \]

Periodicity in longitude

Because the sphere is periodic in \( \phi \), the spline must satisfy

\[ s(\theta, 0) = s(\theta, 2\pi) \]

together with matching of all derivatives at \( \phi = 0 \) and \( \phi = 2\pi \). FITPACK enforces this by using a periodic knot vector and periodic B-spline basis in the \( \phi \) direction.

FITPACK routines

Routine Input
sphere (scattered) Arbitrary \( (\theta_i, \phi_i, r_i) \) on the sphere
spgrid (gridded) Data on a \( (\theta_i, \phi_j) \) grid

The Pole Problem

Analogy with the origin problem

The pole problem on the sphere is the direct analogue of the origin problem in polar coordinates. At the north pole ( \( \theta = 0 \)) and the south pole ( \( \theta = \pi \)), all longitudes \( \phi \) correspond to the same physical point. A naive tensor-product spline would allow different values of \( s(0, \phi) \) at different longitudes, producing a discontinuity at the pole.

Continuity conditions

** \( C^0 \) continuity.** The function value at each pole must be single-valued:

\[ s(0, \phi) = c_{\mathrm{NP}} \quad \text{(constant for all } \phi\text{)}, \qquad s(\pi, \phi) = c_{\mathrm{SP}} \quad \text{(constant for all } \phi\text{)} \]

** \( C^1 \) continuity.** Additionally, the angular derivatives at each pole must be consistent with a well-defined gradient on the sphere. Without this constraint the directional derivative would depend on the approach azimuth in a manner incompatible with the smoothness of the underlying surface.

FITPACK enforces these conditions by imposing linear constraints on the B-spline coefficients near \( \theta = 0 \) and \( \theta = \pi \), reducing the number of free parameters at each pole.

Pole boundary conditions for gridded spheres

For gridded spherical fitting (spgrid), the north and south poles have independently configurable boundary conditions:

Setting Description
z0 Prescribed function value at the pole
exact If .true., the spline passes exactly through z0
continuity Continuity order at the pole (0 = \( C^0 \), 1 = \( C^1 \))
zero_gradient If .true., enforce vanishing gradient at the pole

Each pole is configured independently via BC_north_pole and BC_south_pole, allowing asymmetric physical conditions (e.g., a known temperature at the north pole with a free south pole).

Practical Considerations

  • Arbitrary boundary shape: The scattered polar fitter (polar) accepts a general boundary function \( R(\theta) \) through a function pointer, allowing fitting on non-circular disc-shaped domains. The gridded polar fitter (pogrid) requires a constant radius \( R \).
  • Evaluation grid layout: The gridded sphere evaluation method eval_many returns an output array of shape \( (n_\phi, n_\theta) \), not paired points. This matches the tensor-product structure and allows efficient grid evaluation.
  • Independent pole settings: The gridded sphere supports independent north and south pole boundary conditions, making it possible to impose different physical constraints at each pole without affecting the other.
  • Smoothing vs. interpolation: All four routines (polar, pogrid, sphere, spgrid) support both smoothing and interpolation modes. In smoothing mode the continuity and boundary constraints are incorporated into the penalized least-squares problem; in interpolation mode they appear as hard constraints.
See also
Surface Fitting Theory
Polar Domain Fitting Tutorial
Spherical Spline Fitting Tutorial
Book Reference Index

P. Dierckx, Curve and Surface Fitting with Splines, Oxford University Press, 1993, Chapter 11.