Learn R Programming

vectorialcalculus (version 1.0.5)

osculating_circle3d: Osculating discs and circles of a spatial curve

Description

For a three-dimensional parametric curve, this function constructs numerical approximations to the osculating circles (and associated discs) at a set of parameter values. At each requested point on the curve, it approximates the Frenet frame and the curvature, and then uses this information to define the center and radius of the local osculating circle. Optionally, it can display these circles or discs in an interactive 3D visualization using plotly.

Usage

osculating_circle3d(
  X,
  Y,
  Z,
  a,
  b,
  t_points,
  h = 1e-04,
  plot = FALSE,
  n_samples = 400,
  fill = c("disk", "ring"),
  ru = 24,
  rv = 72,
  colorscale = "Reds",
  opacity = 0.6,
  ring_line = list(color = "red", width = 4, dash = "solid"),
  show_curve = TRUE,
  show_points = TRUE,
  curve_line = list(color = "blue", width = 2, dash = "solid"),
  point_marker = list(color = "black", size = 3, symbol = "circle"),
  show_radius = FALSE,
  radius_phase = 0,
  radius_line = list(color = "orange", width = 5, dash = "solid"),
  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"),
  lighting = list(ambient = 1, diffuse = 0.15, specular = 0, roughness = 1, fresnel = 0),
  tol = 1e-10
)

Value

A list with two components:

data

A tibble with columns t, x, y, z, kappa, cx, cy, cz, radius, Tx, Ty, Tz, Nx, Ny, Nz, Bx, By, Bz, containing the parameter values, the curve coordinates, the numerical curvature, the centers and radii of the osculating circles, and the associated Frenet frame vectors.

plot

A plotly object when plot = TRUE, otherwise NULL.

Arguments

X, Y, Z

Functions of t returning the coordinate components of the curve.

a, b

Numeric endpoints of the parameter interval.

t_points

Numeric vector of parameter values at which osculating circles or discs are constructed.

h

Step size for centered finite-difference approximations.

plot

Logical; if TRUE, creates a 3D visualization using plotly.

n_samples

Number of sample points used to draw the base curve when show_curve = TRUE.

fill

Character; either "disk" for a filled surface or "ring" for the circumference only.

ru

Number of radial subdivisions when drawing a filled disc.

rv

Number of angular subdivisions; also used as the number of points on each ring.

colorscale

Character string giving the plotly colorscale used for the discs.

opacity

Numeric value between 0 and 1 controlling the opacity of the discs when fill = "disk".

ring_line

List with style options for the ring when fill = "ring".

show_curve, show_points

Logical values indicating whether the base curve and the corresponding points on the curve should be displayed.

curve_line, point_marker

Lists with plotly style options for the base curve and the points.

show_radius

Logical; if TRUE, draws a radius segment from the center of each osculating circle to its boundary.

radius_phase

Angle, in radians, that determines the direction of the displayed radius.

radius_line

List with plotly style options for the radius segment.

scene

List with 3D scene settings for the plotly figure.

bg

List defining background colors for the figure, typically with entries paper and plot.

lighting

List with lighting options for add_surface when fill = "disk".

tol

Numeric tolerance used in derivative-based checks and to detect degenerate cases in which curvature or frame vectors cannot be computed reliably.

Details

For each parameter value in t_points, the function:

  • evaluates the curve and approximates its first and second derivatives,

  • constructs approximate tangent, normal and binormal directions,

  • estimates the curvature from the derivative information,

  • defines the center of the osculating circle by moving from the curve point along the normal direction by a distance equal to the reciprocal of the curvature,

  • records the corresponding radius as that same reciprocal quantity.

Depending on the value of fill, the function either:

  • builds a filled disc that lies in the osculating plane and is bounded by the osculating circle, or

  • draws only the circumference corresponding to that circle.

A regular sampling of angles around the osculating circle is used to generate the discrete representation. For filled discs, radial subdivisions are added to obtain a surface mesh. The resulting objects can be combined with a sampled version of the base curve and additional elements such as radius segments.

Examples

Run this code
X <- function(t) cos(t)
Y <- function(t) sin(t)
Z <- function(t) 0.2 * t
osculating_circle3d(
  X, Y, Z,
  a = 0, b = 6 * pi,
  t_points = c(pi, 2 * pi),
  plot = FALSE
)

Run the code above in your browser using DataLab