# Integration on the interval (2, 3.5) with Simpson's rule
ips <- fm_int(fm_mesh_1d(0:4), samplers = cbind(2, 3.5))
plot(ips$x, ips$weight)
# Create integration points for the two intervals [0,3] and [5,10]
ips <- fm_int(
fm_mesh_1d(0:10),
rbind(c(0, 3), c(5, 10))
)
plot(ips$x, ips$weight)
# Convert a 1D mesh into integration points
mesh <- fm_mesh_1d(seq(0, 10, by = 1))
ips <- fm_int(mesh, name = "time")
plot(ips$time, ips$weight)
if (require("ggplot2", quietly = TRUE)) {
#' Integrate on a 2D mesh with polygon boundary subset
ips <- fm_int(fmexample$mesh, fmexample$boundary_sf[[1]])
ggplot() +
geom_sf(data = fm_as_sfc(fmexample$mesh, multi = TRUE), alpha = 0.5) +
geom_sf(data = fmexample$boundary_sf[[1]], fill = "red", alpha = 0.5) +
geom_sf(data = ips, aes(size = weight)) +
scale_size_area()
}
# Individual sampling points:
(ips <- fm_int(0:10, c(0, 3, 5, 6, 10)))
# Sampling blocks:
(ips <- fm_int(0:10, list(c(0, 3), c(5, 6, 10))))
# Continuous integration on intervals
ips <- fm_int(
fm_mesh_1d(0:10, boundary = "cyclic"),
rbind(c(0, 3), c(5, 10))
)
plot(ips$x, ips$weight)
Run the code above in your browser using DataLab