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.
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
)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.
Function returning the x coordinate of the curve as a
function of the parameter t.
Function returning the y coordinate of the curve.
Function returning the z coordinate of the curve.
Lower endpoint of the parameter interval.
Upper endpoint of the parameter interval.
Numeric vector with the parameter values where the frame is computed and optionally plotted.
Step size for centered finite difference approximations.
Logical; if TRUE, shows a 3D plotly visualization
of the curve together with the three vector fields.
Number of points used to sample the curve for plotting.
Base scaling factor for the vector segments. If
NULL, it is estimated from the overall size of the sampled curve.
Style options for drawing the base curve.
Style options for tangent vector segments.
Style options for normal vector segments.
Style options for binormal vector segments.
Logical; if TRUE, the base curve appears in the
plot.
Logical; if TRUE, the evaluation points are
marked on the curve.
Plotly marker style for the evaluation points.
Plotly 3D scene configuration.
Background settings for the plotly figure.
Numeric tolerance used to detect degenerate derivative situations.
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.
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