Learn R Programming

vectorialcalculus (version 1.0.5)

arc_length3d: Numeric arc length of a 3D parametric curve

Description

Computes a numerical approximation to the arc length of the parametric curve \((X(t), Y(t), Z(t))\) on the interval \([a, b]\) by integrating the speed \(\sqrt{(dx/dt)^2 + (dy/dt)^2 + (dz/dt)^2}\).

Usage

arc_length3d(
  X,
  Y,
  Z,
  a,
  b,
  h = 1e-06,
  method_int = c("romberg", "integrate"),
  n_samples = 400,
  plot = FALSE,
  plot_mode = "lines",
  plot_line = list(color = "blue", width = 3, dash = "solid"),
  plot_marker = NULL,
  plot_title = NULL,
  plot_scene = list(xaxis = list(title = "x(t)"), yaxis = list(title = "y(t)"), zaxis =
    list(title = "z(t)")),
  plot_bg = list(paper = "white", plot = "white")
)

Value

A single numeric value: the approximated arc length of the curve on the interval \([a, b]\).

Arguments

X, Y, Z

Functions of one variable t defining the parametric curve coordinates.

a, b

Numeric parameter limits for t.

h

Numeric step size for centered finite differences used to approximate the derivatives \(dX/dt\), \(dY/dt\), and \(dZ/dt\).

method_int

Character string. Either "romberg" (requires the pracma package) or "integrate" (base R).

n_samples

Integer. Number of sample points used when plotting the curve (if plot = TRUE).

plot

Logical. If TRUE, the function also produces a 3D visualization of the curve using plot_curve3d().

plot_mode

Character string passed to plot_curve3d() as the mode argument.

plot_line

List with line styling options passed to plot_curve3d().

plot_marker

Optional list with marker styling options passed to plot_curve3d(), or NULL.

plot_title

Optional title for the plot. If NULL, a title including the estimated arc length is generated.

plot_scene

List specifying 3D axes and options, passed to plot_curve3d().

plot_bg

List with background colors, passed to plot_curve3d().

Details

Derivatives are approximated by centered finite differences and the integral is computed either by Romberg integration (via pracma) or by integrate from base R. Optionally, the curve can be visualized with plot_curve3d().

See Also

curve_sample3d(), plot_curve3d()

Examples

Run this code
X <- function(t) t^2 * cos(t)
Y <- function(t) t^3 * sin(3 * t)
Z <- function(t) t
arc_length3d(X, Y, Z, 0, 2 * pi)

# \donttest{
# if (requireNamespace("plotly", quietly = TRUE)) {
#   arc_length3d(
#     X, Y, Z, 0, 2 * pi,
#     plot = TRUE,
#     plot_line = list(color = "red", width = 3),
#     n_samples = 300
#   )
# }
# }

Run the code above in your browser using DataLab