Learn R Programming

vectorialcalculus (version 1.0.5)

cylindrical_surface3d: Ruled surface along a 3D parametric curve

Description

Constructs a ruled surface generated by a three-dimensional parametric curve and a chosen direction field. At each sampled point on the curve, a straight segment is extended in a specified direction, producing a surface composed of line elements. Optionally, the resulting surface can be visualized using plotly.

Usage

cylindrical_surface3d(
  X,
  Y,
  Z,
  a,
  b,
  s_range,
  dir,
  n_t = 200,
  n_s = 60,
  plot = FALSE,
  surface_colorscale = "Blues",
  surface_opacity = 0.35,
  show_surface_grid = TRUE,
  surface_grid_color = "rgba(60,80,200,0.25)",
  surface_grid_width = 1,
  show_curve = TRUE,
  curve_line = list(color = "red", width = 2, dash = "solid"),
  show_edge_a = TRUE,
  show_edge_b = FALSE,
  edge_line = list(color = "blue", width = 2, dash = "solid"),
  show_rulings = TRUE,
  rulings_count = 12,
  rulings_at = NULL,
  rulings_line = list(color = "black", width = 1, dash = "solid"),
  show_axis_grid = FALSE,
  scene = list(aspectmode = "data", xaxis = list(title = "x"), yaxis = list(title = "y"),
    zaxis = list(title = "z")),
  bg = list(paper = "white", plot = "white"),
  lighting = list(ambient = 1, diffuse = 0.15, specular = 0, roughness = 1, fresnel = 0)
)

Value

A list with:

  • t_seq, s_seq: parameter grids used to build the mesh,

  • Xmat, Ymat, Zmat: matrices of coordinates for the ruled surface,

  • curve: data frame with the sampled generating curve,

  • edge_a, edge_b: data frames for boundary edges (possibly NULL if not requested),

  • u_hat: normalized ruling direction vector.

Arguments

X, Y, Z

Functions of one variable t returning the coordinate components of the base curve.

a, b

Numeric values giving the endpoints of the parameter interval.

s_range

Numeric vector of length two giving the lower and upper bounds for the ruling parameter.

dir

Numeric vector of length three c(ux, uy, uz) giving the ruling direction. It will be normalized internally.

n_t, n_s

Integers giving the sampling resolution along the t and s directions.

plot

Logical; if TRUE, displays the ruled surface using plotly.

surface_colorscale

Character string or vector specifying the colorscale used for the surface.

surface_opacity

Numeric value between 0 and 1 controlling the opacity of the surface.

show_surface_grid

Logical; if TRUE, draws grid lines on the surface.

surface_grid_color

Color for the surface grid lines.

surface_grid_width

Numeric width for the grid lines.

show_curve

Logical; if TRUE, overlays the generating curve.

curve_line

List of plotly style options for the curve.

show_edge_a, show_edge_b

Logical; if TRUE, draws the boundary edges at the extremes of the ruling parameter.

edge_line

List of plotly style options for boundary edges.

show_rulings

Logical; if TRUE, draws a subset of rulings on the surface.

rulings_count

Integer giving the number of rulings to draw when rulings_at is not provided.

rulings_at

Optional numeric vector giving the parameter values at which rulings should be displayed.

rulings_line

List of plotly style options for displayed rulings.

show_axis_grid

Logical; if TRUE, shows axis gridlines in the 3D scene.

scene

Optional list with 3D scene settings for plotly.

bg

Optional list with background color settings for the figure.

lighting

Optional list with lighting parameters for surface shading in plotly.

Details

The function samples the base curve at n_t parameter values and, for each sampled point, generates a set of points along a line segment determined by the ruling parameter. These segments are interpolated over the interval specified in s_range.

In this implementation, the ruling direction is given by a fixed three-dimensional vector dir. This vector is normalized internally before constructing the surface.

If plot = TRUE, a 3D visualization is produced using plotly. The plot may include the ruled surface, grid lines on the surface, boundary edges corresponding to the extremes of the ruling parameter, and a selection of rulings. The generating curve can also be displayed.

Examples

Run this code
X <- function(t) cos(t)
Y <- function(t) sin(t)
Z <- function(t) 0.3 * t
dir_vec <- c(0, 0, 1)
rs <- cylindrical_surface3d(
  X, Y, Z,
  a = 0, b = 2 * pi,
  s_range = c(-0.2, 0.2),
  dir = dir_vec,
  n_t = 100, n_s = 40,
  plot = FALSE
)

Run the code above in your browser using DataLab