Learn R Programming

vectorialcalculus (version 1.0.5)

frenet_frame3d: Frenet-Serret frame for a 3D parametric curve

Description

Computes the Frenet-Serret frame, that is, the tangent, normal and binormal vectors of a three dimensional parametric curve at selected values of the parameter. The frame is obtained from numerical approximations of the first and second derivatives of the curve. Optionally, the curve and the three vector fields can be displayed in a 3D interactive visualization using plotly.

Usage

frenet_frame3d(
  X,
  Y,
  Z,
  a,
  b,
  t_points,
  h = 1e-04,
  plot = FALSE,
  n_samples = 400,
  vec_scale = NULL,
  curve_line = list(color = "blue", width = 2, dash = "solid"),
  T_line = list(color = "red", width = 4, dash = "solid"),
  N_line = list(color = "green", width = 4, dash = "solid"),
  B_line = list(color = "black", width = 4, dash = "solid"),
  show_curve = TRUE,
  show_points = TRUE,
  point_marker = list(color = "blue", size = 3, symbol = "circle"),
  scene = list(aspectmode = "data", xaxis = list(title = "x(t)"), yaxis = list(title =
    "y(t)"), zaxis = list(title = "z(t)")),
  bg = list(paper = "white", plot = "white"),
  tol = 1e-10
)

Value

A tibble containing the parameter values and the coordinates of:

  • the point on the curve,

  • the tangent vector,

  • the normal vector,

  • the binormal vector,

  • a numerical estimate of the curvature.

Columns are named t, x, y, z, Tx, Ty, Tz, Nx, Ny, Nz, Bx, By, Bz, kappa.

Arguments

X

Function returning the x coordinate of the curve as a function of the parameter t.

Y

Function returning the y coordinate of the curve.

Z

Function returning the z coordinate of the curve.

a

Lower endpoint of the parameter interval.

b

Upper endpoint of the parameter interval.

t_points

Numeric vector with the parameter values where the frame is computed and optionally plotted.

h

Step size for centered finite difference approximations.

plot

Logical; if TRUE, shows a 3D plotly visualization of the curve together with the three vector fields.

n_samples

Number of points used to sample the curve for plotting.

vec_scale

Base scaling factor for the vector segments. If NULL, it is estimated from the overall size of the sampled curve.

curve_line

Style options for drawing the base curve.

T_line

Style options for tangent vector segments.

N_line

Style options for normal vector segments.

B_line

Style options for binormal vector segments.

show_curve

Logical; if TRUE, the base curve appears in the plot.

show_points

Logical; if TRUE, the evaluation points are marked on the curve.

point_marker

Plotly marker style for the evaluation points.

scene

Plotly 3D scene configuration.

bg

Background settings for the plotly figure.

tol

Numeric tolerance used to detect degenerate derivative situations.

Details

At each parameter value in t_points, the function:

  • computes finite difference approximations of the first and second derivatives of the curve,

  • normalizes the first derivative to obtain the unit tangent direction,

  • uses the first and second derivatives to construct a principal normal direction,

  • constructs the binormal direction as a unit vector orthogonal to both the tangent and the normal,

  • evaluates a numerical estimate of the curvature using the same derivative information.

If the derivative information is too small or nearly degenerate (for example, when the tangent direction cannot be reliably obtained), some components of the frame may be set to NA. The tolerance parameter tol controls how these situations are detected.

When plot = TRUE, the function displays:

  • a sampled representation of the curve,

  • the evaluation points,

  • short line segments indicating the tangent, normal and binormal directions at each evaluation point.

All visual elements can be styled or shown selectively through the corresponding arguments.

Examples

Run this code
X <- function(t) t*cos(t)
Y <- function(t) t*sin(3*t)
Z <- function(t) t
frenet_frame3d(
  X, Y, Z, a = 0, b = 2*pi,
  t_points = c(pi/3, pi, 5*pi/3)
)

Run the code above in your browser using DataLab