Constructs a numerical representation of the planar region bounded by
two functions of one variable. The region consists of all points whose
horizontal coordinate lies between a and b, and whose
vertical coordinate lies between the values returned by H1(x)
and H2(x). Optionally, the region can be displayed either as a
two-dimensional filled subset of the plane or as a thin surface in
three dimensions using plotly.
xy_region(
H1,
H2,
a,
b,
D,
plot = TRUE,
n_curve = 800,
fill = FALSE,
fillcolor = "rgba(49,130,189,0.25)",
boundary_line = list(color = "blue", width = 2),
partition_line = list(color = "blue", width = 1),
show_end_edges = TRUE,
axis_equal = TRUE,
as_3d = FALSE,
plane_z = 0,
n_u = 30,
surface_colorscale = "Blues",
surface_opacity = 0.3,
show_surface_grid = TRUE,
surface_grid_color = "rgba(60,80,200,0.25)",
surface_grid_width = 1,
scene = list(aspectmode = "data", xaxis = list(title = "x"), yaxis = list(title = "y"),
zaxis = list(title = "z")),
bg = list(paper = "white", plot = "white")
)A list containing:
x: the sample points along the horizontal axis,
y1, y2: the sampled boundary values,
y_low, y_high: the lower and upper envelopes
pmin(H1,H2) and pmax(H1,H2),
x_part: the partition points used in the horizontal
direction,
fig: a plotly object for visualization if
plot = TRUE and plotly is available; otherwise
NULL.
Functions of one variable returning the lower and upper
vertical bounds at each value of x.
Numeric endpoints of the interval for x. It is assumed
that a < b.
Integer giving the number of subdivisions in the horizontal direction (number of vertical strips).
Logical; if TRUE, produces a visualization using
plotly.
Integer giving the number of points for sampling the boundary curves.
Logical; if TRUE, fills the two-dimensional region.
Character string defining the fill color in 2D mode.
List with plotly style options for drawing the boundary curves.
List with style parameters for vertical partition lines.
Logical; if TRUE, draws boundary segments at
the endpoints x = a and x = b.
Logical; if TRUE, enforces equal scaling on both
axes in two dimensions.
Logical; if TRUE, draws the region as a thin
three-dimensional plate.
Numeric height at which to draw the region when
as_3d = TRUE.
Integer number of internal subdivisions used for discretization of the region in the cross-section (between lower and upper boundary).
Character string specifying a plotly colorscale for the three-dimensional mode.
Numeric value between 0 and 1 controlling the transparency of the surface in 3D mode.
Logical; if TRUE, overlays grid lines on
the plotted surface in 3D mode.
Character string giving the color of the grid lines in 3D mode.
Numeric width of the grid lines in 3D mode.
Optional list of plotly scene parameters for three-dimensional rendering.
Optional list defining the background colors of the figure,
typically with components paper and plot.
The function samples the interval [a, b] at n_curve points
to represent the boundary curves. The interval [a, b] is also
subdivided into D vertical strips. For each strip, the values
H1(x) and H2(x) are evaluated to define the vertical bounds
of the region.
Depending on the arguments, the function can:
build a data grid suitable for numerical integration or visualization,
draw a two-dimensional depiction of the region, possibly filled with a selected color,
generate a simple three-dimensional visualization where the region is drawn as a thin plate at a chosen height.
Additional options allow drawing grid lines, showing the boundary curves, controlling colors and transparency, and adjusting the aspect ratio.
H1 <- function(x) 0
H2 <- function(x) 1 - x
xy_region(H1, H2, a = 0, b = 1, D = 20, plot = FALSE)
Run the code above in your browser using DataLab