Plot Morse-Smale Trajectories from Point
Source:R/2d_smooth_morse_smale.R
plot.morse.smale.trajectories.from.point.RdVisualizes gradient flow trajectories (both ascending and descending) from a specific starting point. Shows the trajectories on a contour plot background, marks the starting point and endpoints (critical points), and optionally adds directional arrows along the trajectories.
Usage
# S3 method for class 'morse.smale.trajectories.from.point'
plot(
x,
y,
mixture,
grid,
step = 0.01,
show.arrows = TRUE,
use.custom.legend = FALSE,
...
)Arguments
- x
Starting x coordinate
- y
Starting y coordinate
- mixture
Object containing:
f: Function taking (x, y) and returning scalar value
gradient: Function taking (x, y) and returning gradient vector c(dx, dy)
- grid
Grid object created by create.grid for contour plot background
- step
Step size for gradient flow integration (default 0.01)
- show.arrows
Logical, whether to show directional arrows on trajectories
- use.custom.legend
Logical, whether to use custom legend.
- ...
Additional arguments passed to function.contours.plot
Value
Invisible list containing:
- ascending
Matrix of points along ascending trajectory
- descending
Matrix of points along descending trajectory
Examples
if (FALSE) { # \dontrun{
grid <- create.grid(50)
mixture <- list(
f = function(x, y) -((x-0.3)^2 + (y-0.7)^2) - 2*((x-0.7)^2 + (y-0.3)^2),
gradient = function(x, y) {
c(-2*(x-0.3) - 4*(x-0.7), -2*(y-0.7) - 4*(y-0.3))
}
)
# Plot trajectories from a point
result <- plot.morse.smale.trajectories.from.point(0.5, 0.5, mixture, grid)
} # }