Plot Morse-Smale Complex from Function
Source:R/2d_smooth_morse_smale.R
morse.smale.complex.plot.RdCreates a comprehensive visualization of the Morse-Smale complex by plotting contour lines and gradient flow trajectories from a grid of sample points. Ascending trajectories (to maxima) are shown in red, descending trajectories (to minima) are shown in blue.
Arguments
- grid
Grid object created by create.grid containing x, y coordinates
- mixture
Object containing:
f: Function taking (x, y) and returning scalar value
gradient: Function taking (x, y) and returning gradient vector c(dx, dy)
- n_sample_points
Number of sample points along each axis for trajectory visualization
- ...
Additional arguments passed to function.contours.plot
Examples
if (FALSE) { # \dontrun{
# Create a simple function with two critical points
grid <- create.grid(50)
mixture <- list(
f = function(x, y) sin(3*pi*x) * cos(3*pi*y),
gradient = function(x, y) {
c(3*pi*cos(3*pi*x)*cos(3*pi*y),
-3*pi*sin(3*pi*x)*sin(3*pi*y))
}
)
morse.smale.complex.plot(grid, mixture, n_sample_points = 10)
} # }