Learn R Programming

misc3d (version 0.3-1)

parametric3d: Draw a 3D Parametric Plot

Description

Plot a two-parameter surface in three dimensions.

Usage

parametric3d(fx, fy, fz, umin, umax, vmin, vmax, n = 100, add = FALSE, ...)

Arguments

fx,fy,fz
vectorized functions of u and v to compute the x, y, and z coordinates.
umin
numeric; the minimum value of u.
umax
numeric; the maximum value of u.
vmin
numeric; the minimum value of v.
vmax
numeric; the maximum value of v.
n
the number of equally spaced u and v values to use.
add
logical; if TRUE, add to current rgl graph.
...
material and texture properties. See rgl.material for details.

Details

Analogous to Mathematica's Param3D. Evaluates the functions fx, fy, and fz specifying the coordinates of the surface at an equally spaced grid of values for the parameters u and v.

References

Daniel Adler, Oleg Nenadic and Walter Zucchini (2003) RGL: A R-library for 3D visualization with OpenGL

See Also

rgl.quads,rgl.surface, rgl.material,scatterplot3d.

Examples

Run this code
#Example 1: Ratio-of-Uniform sampling region of bivariate normal
  parametric3d(fx = function(u, v) u * exp(-0.5 * (u^2 + v^2 -
                      2 * 0.75 * u * v)/sqrt(1-.75^2))^(1/3),
               fy = function(u, v) v * exp(-0.5 * (u^2 + v^2 -
                      2 * 0.75 * u * v)/sqrt(1-.75^2))^(1/3),
               fz = function(u, v) exp(-0.5 * (u^2 + v^2 - 2 * 0.75 * u * 
                      v)/sqrt(1-.75^2))^(1/3),
               umin = -20, umax = 20, vmin = -20, vmax = 20, 
               n = 100)	

  #Example 2: Ratio-of-Uniform sampling region of Bivariate t      
  parametric3d(fx = function(u,v) u*(dt(u,2) * dt(v,2))^(1/3), 
               fy = function(u,v) v*(dt(u,2) * dt(v,2))^(1/3),
               fz = function(u,v) (dt(u,2) * dt(v,2))^(1/3), 
               umin = -20, umax = 20, vmin = -20, vmax = 20, 
               n = 100, color = "green", alpha=1.0)

  #Example 3: Surface of revolution
  parametric3d(fx = function(u,v) u,
               fy = function(u,v) sin(v)*(u^3+2*u^2-2*u+2)/5,
               fz = function(u,v) cos(v)*(u^3+2*u^2-2*u+2)/5,
               umin = -2.3, umax = 1.3, vmin = 0, vmax = 2*pi)

Run the code above in your browser using DataLab