Point Plots and Space Curves

by Theo Gray

This notebook defines the functions PointPlot, PointPlot3D, PointParamPlot3D, SpaceCurve, and PointSpaceCurve.  These functions let you make discrete point plots in two and three dimensions.  The SpaceCurve and PointSpaceCurve functions let you make three-dimensional functions of one parameter (lines or points in 3D).

Examples

Each of the functions defined in this notebook is a variation of either Plot, Plot3D, or ParametricPlot3D.  The arguments are quite similar to these standard functions.  
Following are descriptions of each of the functions.

PointPlot

PointPlot[ f, {x, min, max, (step)}] produces a plot of f(x) vs. x.  Here is an example:

PointPlot[Sin[x], {x, 0, 2 Pi, 0.2}]

PointPlot3D

PointPlot3D[ f, {x, min, max, (step)}, {y, min, max, (step)}] produces a plot of f(x, y), plotted with points instead of surfaces.

PointPlot3D[x y, {x, -4, 4, 0.5}, {y, -4, 4, 0.5}, 
			BoxRatios->{1,1,1}]

PointParamPlot3D

PointParamPlot3D[{x,y,z}, {u, min, max, (step)}, {v, min, max, (step)}] produces a parametric plot of (x(u,v), y(u,v), z(u,v)), plotted with points instead of surfaces.

PointParamPlot3D[{Sin[u] Cos[v], 
						Sin[u] Sin[v], Cos[u]}, 
		{u, 0, Pi, Pi/15}, {v, 0, 2 Pi, Pi/15}, 
		BoxRatios->{1,1,1}]

SpaceCurve

SpaceCurve[{x,y,z}, {u, min, max, (step)}] produces a parametric plot of (x(u), y(u), z(u)), with the calculated points connected by straight lines.

SpaceCurve[{u Sin[u], u Cos[u], u}, 
		   {u, 0, 15, 0.15}, BoxRatios->{1,1,1}]

PointSpaceCurve

PointSpaceCurve[{x,y,z}, {u, min, max, (step)}] produces a parametric plot of (x(u), y(u), z(u)), with the calculated points shown as dots.

PointSpaceCurve[{u Sin[u], u Cos[u], u^2}, 
			{u, 0, 15, 0.30}, BoxRatios->{1,1,1}]

Implementation

Remove previous definitions for the functions defined in this file:

Remove[PointPlot, PointParamPlot3D, PointPlot3D,
		SpaceCurve, PointSpaceCurve];

Begin this package:

BeginPackage["PointPlots`"];

Define the usage strings for each of the functions:

PointPlot::usage =
	"PointPlot[f, {u, u0, u1, (du)}], (options)] 	produces a 2D plot made out of points. 	Options are passed to Show[]";

PointPlot3D::usage =
	"PointPlot3D[f, {x, x0, x1, (dx)}, 	{y, y0, y1, (dy)}, (options)] 	produces a 3D plot made out of points. 	Options are passed to Show[]";

PointParamPlot3D::usage =
	"PointParamPlot3D[{x, y, z}, {u, u0, u1, (du)}, 	{v, v0, v1, (dv)}, (options)] 	produces a 3D parametric plot made out of points. \ 
	Options are passed to Show[]";

SpaceCurve::usage =
	"SpaceCurve[{x, y, z}, {u, u0, u1, (du)}, 	(options)] 	produces a 3D space curve. 	Options are passed to Show[]";

PointSpaceCurve::usage =
	"PointSpaceCurve[{x, y, z}, 	{u, u0, u1, (du)}, (options)] 	produces a set of points in 3D. 	Options are passed to Show[]";

Begin the private part of this package:

Begin["`Private`"];
`plotpoints = PlotPoints /. Options[Plot3D];

Define PointPlot:

Attributes[PointPlot] = {HoldFirst};

PointPlot[function_, range:{x_,___}, options___] := 
			ListPlot[Table[{x, function}, range], options];

Define PointParamPlot3D:

Attributes[PointParamPlot3D] = {HoldFirst};

PointParamPlot3D[fun:{_, _, _}, 
	{u_, u0_, u1_, du_:((u1-u0)/(plotpoints-1))}, 
	{v_, v0_, v1_, dv_:((v1-v0)/(plotpoints-1))}, opts___] :=
	Show[Graphics3D[Table[Point[N[fun]], 
						{u, u0, u1, du}, 
						{v, v0, v1, dv}]], opts];

Define PointPlot3D (in terms of PointParamPlot3D):

Attributes[PointPlot3D] = {HoldFirst};

PointPlot3D[fun_, ulim:{u_, ___}, vlim:{v_, ___}, opts___] :=
	PointParamPlot3D[ {u, v, fun}, ulim, vlim, opts];

Define SpaceCurve:

Attributes[SpaceCurve] = {HoldFirst};

SpaceCurve[fun:{_, _, _}, 
  {u_, u0_, u1_, du_:((u1-u0)/(plotpoints-1))}, opts___] :=
	Show[Graphics3D[Line[Table[N[fun], 
	                     {u,u0,u1,du}]]], opts];

Define PointSpaceCurve:

Attributes[PointSpaceCurve] = {HoldFirst}

PointSpaceCurve[fun:{_, _, _}, 
  {u_, u0_, u1_, du_:((u1-u0)/(plotpoints-1))}, opts___] :=
	Show[Graphics3D[Table[Point[N[fun]], 
	                {u,u0,u1,du}]], opts];

End this package:

End[];
EndPackage[];