Compute a numerical approximation of the line integral of a vector field along a parametric space curve and optionally draw a three dimensional visualization of the curve together with arrows of the field.
line_integral3d_work(
field,
r,
a,
b,
plot = TRUE,
n_curve = 600,
n_field = 7,
field_ranges = NULL,
pad = 0.15,
arrows = c("both", "line", "cone", "none"),
arrow_scale = 0.1,
normalize_bias = 1,
scene = list(aspectmode = "data", xaxis = list(title = "x"), yaxis = list(title = "y"),
zaxis = list(title = "z")),
bg = list(paper = "white", plot = "white")
)A list with components:
value: numeric value of the line integral (work).
fig: plotly object when plot = TRUE, otherwise
NULL.
field_box: list with numeric ranges used for the field
grid, with components x, y and z.
Function that represents the vector field. It must be a function of three or four numeric arguments. In the three argument form the arguments are x, y and z. In the four argument form the arguments are x, y, z and t. The function must return a numeric vector of length three.
Function of one numeric argument t that returns a numeric vector c(x, y, z) of length three with the coordinates of the curve.
Numeric scalar with the lower value of the parameter interval.
Numeric scalar with the upper value of the parameter interval.
It must satisfy b > a.
Logical value. If TRUE, a plotly object with the field
arrows and the curve is created.
Integer number of sampled points on the curve.
Integer number of grid points per axis for the field
arrows. The total number of arrows is n_field^3.
Optional list with named components x, y
and z, each a numeric vector of length two giving the range used
to build the field grid. If NULL, the ranges are taken from the
bounding box of the curve and expanded by pad.
Numeric fraction used to expand the automatic field ranges.
Character string that selects which arrow style is drawn.
One of "both", "line", "cone" or "none".
Numeric factor that controls the length of the arrows as a fraction of the size of the domain.
Numeric value used to regularize the scaling of the field magnitude when computing arrows.
List of plotly scene options passed to plotly::layout().
List with two character elements named paper and
plot that control the background colours in the plotly layout.
The parameter t runs from a to b. The curve r(t) must return a numeric vector of length three. The field field(x, y, z) may optionally also depend on t through a fourth argument.
# \donttest{
field <- function(x, y, z) c(-y, x, 0.2*z)
r <- function(t) c(cos(t), sin(t), 0.25*t)
out <- line_integral3d_work(
field = field, r = r, a = 0, b = 2*pi,
plot = FALSE, n_curve = 200, n_field = 5
)
out$value
# }
Run the code above in your browser using DataLab