## vmm.spacecurve.parametric Class SpaceCurveParametric

java.lang.Object
vmm.core.Exhibit
vmm.core3D.Exhibit3D
vmm.spacecurve.SpaceCurve
vmm.spacecurve.parametric.SpaceCurveParametric

All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
CinquefoilKnot, ConstantCurvature, ConstantTorsion, Figure8Knot, GrannyKnot, Helix, SphericalCurve, SquareKnot, TorusKnot, UserSpaceCurveKappaTau, UserSpaceCurveParametric

public abstract class SpaceCurveParametricextends SpaceCurve

A space curve that is defined by parametric equations, giving points of the form (x(t),y(t),z(t)). A parametric curve can be rendered as a "tube" that surrounds the curve; this tube has square cross section, with the orientation of the square at a given point depending on the torsion of the curve at that point. A SpaceCurveParametric renders itself as a tube if it is being drawn in a View3DLit. In a plain View3D, it renders itself as a curve.

Nested Class Summary
 class SpaceCurveParametric.SpaceCurveParametricView
Defines the default View of a SpaceCurveParametric.
static class SpaceCurveParametric.SpaceCurveParametricViewAsTube
Defines a tube view of a SpaceCurveParametric.

Field Summary
protected  RealParam tmax
The maximum value of t for points on the curve.
protected  RealParam tmin
The minimum value of t for points on the curve.
protected  IntegerParam tResolution
The number of t-values for points on the curve.
protected  Grid3D tube
Represents the surface of the tube, when this exhibit is rendered as a tube.
protected  IntegerParam tubeSides
The number of sides around the tube, from 3 to 20.
protected  RealParam tubeSize
The length of one of the square cross sections of the tube, when this exhibit is rendered as a tube.
protected  double[] tVals
The t-values used to compute the points (x(t),y(t),z(t)) on the curve.

Fields inherited from class vmm.spacecurve.SpaceCurve
points

Fields inherited from class vmm.core3D.Exhibit3D
defaultViewpoint, defaultViewUp, previousTransform3D

Fields inherited from class vmm.core.Exhibit
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform

Constructor Summary
SpaceCurveParametric()

Method Summary
protected  void computeDrawData3D(View3D view, boolean exhibitNeedsRedraw, Transform3D previousTransform, Transform3D newTransform)
Computes the data needed to render the exhibit.
protected  Vector3D deriv1(double t)
Finds the derivative (x'(t),y'(t),z'(t)) at a given point on the curve.
protected  Vector3D deriv2(double t)
Finds the second derivative (x''(t),y''(t),z''(t)) at a given point on the curve.
protected  void doDraw3D(java.awt.Graphics2D g, View3D view, Transform3D transform)
Draws either a tube view or a regular curve view of this exhibit, depending on the type of View in which the curve is being rendered.
 Vector3D geographicCoordinates(double theta, double phi)
Computes spherical coordinates (x,y,z)(theta, phi).
 ActionList getActionsForView(View view)
Returns a list of actions that can be applied to this exhibit in the specified view.
 View[] getAlternativeViews()
Returns an array containing a single item, which is a View of type View3DLit.
 Animation getBuildAnimation(View view)
Returns a build animation of the tube view of the curve, that shows the tube being constructed from back to front.
protected  Vector3D getCenterOfPoints(Vector3D[] pointSet, int numPoints)
Returns the center of the first numPoints of the array pointSet.
 Animation getCreateAnimation(View view)
Returns an animation that shows the curve being drawn bit-by-bit.
 View getDefaultView()
Returns a View of type SpaceCurveParametric.SpaceCurveParametricView as the default view of this curve.
 double getT(int index)
Returns the t-value used to calculate the i-th point (x(t),y(t),z(t)) on the curve.
 int getTResolution()
Returns the t-resolution, the number of subintervals into which the interval is divided.
protected  void makePoints()
Computes the array of points on the curve, using the value(double) function and the values of the tmin, tmax, and tResolution parameters.
 Vector3D[] makeRepereMobile(double t)
Returns an array of four vectors representing the Repere Mobile to the curve at a specified t value.
protected abstract  Vector3D value(double t)
Returns a point (x(t), y(t), z(t)) on the curve, given a value of t.

Methods inherited from class vmm.spacecurve.SpaceCurve
getPoint, getPointCount

Methods inherited from class vmm.core3D.Exhibit3D
computeDrawDataHook, doDrawHook, getDefaultTransform, getDefaultViewpoint, getDefaultViewUp, setDefaultViewpoint, setDefaultViewUp

Methods inherited from class vmm.core.Exhibit
addChangeListener, addDecoration, addExtraXML, addParameter, addView, clearDecorations, computeDrawData, doDraw, fireExhibitChangeEvent, forceRedraw, getAdditionalAnimationsForView, getDecorations, getDefaultBackground, getDefaultForeground, getDefaultWindow, getFramesForMorphing, getMorphingAnimation, getName, getParameterByName, getParameters, getSettingsCommandsForView, getTitle, getUseFilmstripForMorphing, getViews, parameterChanged, readExtraXML, removeChangeListener, removeDecoration, removeParameter, removeView, render, setDefaultBackground, setDefaultForeground, setDefaultWindow, setDefaultWindow, setFramesForMorphing, setName, setUseFilmstripForMorphing, stateChanged

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

### tResolution

protected IntegerParam tResolution
The number of t-values for points on the curve. Points of the form (x(t),y(t),z(t)) are computed for 1 plus this many values of t, and these points are joined by line segments to draw the curve. Note that the starting and ending values of t are given by the values of tmin and tmax. This interval is divided into tResolution sub-intervals, giving tResolution+1 points. The default value is 200.

### tmin

protected RealParam tmin
The minimum value of t for points on the curve. The default value is -5.

### tmax

protected RealParam tmax
The maximum value of t for points on the curve. The default value is 5.

### tVals

protected double[] tVals
The t-values used to compute the points (x(t),y(t),z(t)) on the curve. These are evenly spaced between the minimum and maximum t-values.

### tube

protected Grid3D tube
Represents the surface of the tube, when this exhibit is rendered as a tube.

### tubeSize

protected RealParam tubeSize
The length of one of the square cross sections of the tube, when this exhibit is rendered as a tube. The default value is 0.25.

### tubeSides

protected IntegerParam tubeSides
The number of sides around the tube, from 3 to 20.

Constructor Detail

### SpaceCurveParametric

public SpaceCurveParametric()
Method Detail

### makePoints

protected void makePoints()
Computes the array of points on the curve, using the value(double) function and the values of the tmin, tmax, and tResolution parameters. Subclasses should not need to override this method.

Specified by:
makePoints in class SpaceCurve

### getCenterOfPoints

protected Vector3D getCenterOfPoints(Vector3D[] pointSet,
int numPoints)
Returns the center of the first numPoints of the array pointSet.

### value

protected abstract Vector3D value(double t)
Returns a point (x(t), y(t), z(t)) on the curve, given a value of t. The return value can be null, indicating a break in the curve. Subclasses must define this method to specify a particular curve.

### deriv1

protected Vector3D deriv1(double t)
Finds the derivative (x'(t),y'(t),z'(t)) at a given point on the curve. This class defines the derivative using an approximation based on nearby points on the curve. While this is probably good enough, subclasses can override this if they want, to provide an exact formula for the derivative. The return value can be null if the curve or its derivative is undefined at the specified value of t.

### deriv2

protected Vector3D deriv2(double t)
Finds the second derivative (x''(t),y''(t),z''(t)) at a given point on the curve. This class defines the second derivative using an approximation based on nearby points on the curve. While this is probably good enough, subclasses can override this if they want, to provide an exact formula for the derivative. The return value can be null if the curve or its second derivative is undefined at the specified value of t.

### geographicCoordinates

public Vector3D geographicCoordinates(double theta,
double phi)
Computes spherical coordinates (x,y,z)(theta, phi). The z-axis is the pol-direction, theta = 0 gives (0,0,1), theta \in [0, pi], phi \in [0, 2 pi].

### getT

public double getT(int index)
Returns the t-value used to calculate the i-th point (x(t),y(t),z(t)) on the curve.

### getTResolution

public int getTResolution()
Returns the t-resolution, the number of subintervals into which the interval is divided. The size of the array that defines the curve is one plus this value.

### makeRepereMobile

public Vector3D[] makeRepereMobile(double t)
Returns an array of four vectors representing the Repere Mobile to the curve at a specified t value. The array has length 4. The first vector is the point on the curve, and the other three vectors are the unit tangent, unit normal, and unit bi-normal to the curve at that point. The return value can be null, if the curve or its first or second derivative is not defined at the specified point. If the return value is non-null, then all four vectors in the returned array are non-null.

### getDefaultView

public View getDefaultView()
Returns a View of type SpaceCurveParametric.SpaceCurveParametricView as the default view of this curve. In this view, the curve appears as a curve.

Overrides:
getDefaultView in class SpaceCurve

### getAlternativeViews

public View[] getAlternativeViews()
Returns an array containing a single item, which is a View of type View3DLit. This is an alternative view of the curve in which the curve appears as a tube that surrounds the curve itself.

Overrides:
getAlternativeViews in class Exhibit
Returns:
An array containing alternative views for this exhibit. In the top-level Exhibit class, the return value is null.

### getActionsForView

public ActionList getActionsForView(View view)
Returns a list of actions that can be applied to this exhibit in the specified view. The list depends on whether the view is of type SpaceCurveParametricView or View3DLit.

Overrides:
getActionsForView in class Exhibit

### getCreateAnimation

public Animation getCreateAnimation(View view)
Returns an animation that shows the curve being drawn bit-by-bit.

Overrides:
getCreateAnimation in class Exhibit
Parameters:
view - The View where the creation animation will be shown. If this is null or if it is not an instance of SpaceCurveParametric.SpaceCurveParametricView, then the return value is null. The create animation is not used for a tube view of the curve; a build animation is used instead. A curce can be shown in a plaine View3D, but in that case no creation or build animation is used.
Returns:
A creation animation for the given View of this Exhibit. The return value can be null to indicate that no creation animation is to be run.
getBuildAnimation(View)

### getBuildAnimation

public Animation getBuildAnimation(View view)
Returns a build animation of the tube view of the curve, that shows the tube being constructed from back to front. If the view is not a View3DLit, then the return value is null. Note that a build animation is used only for the tube view of the curve; for the regular view, a create animation is used instead.

Overrides:
getBuildAnimation in class Exhibit
Parameters:
view - The view into which the build animation will be installed.
Returns:
The return value in this top-level Exhibit class is null.
getCreateAnimation(View)

### computeDrawData3D

protected void computeDrawData3D(View3D view,
boolean exhibitNeedsRedraw,
Transform3D previousTransform,
Transform3D newTransform)
Computes the data needed to render the exhibit. For a regular curve view, the computeDrawData method from the superclass is called. For a tube view in a View3DLit, the data for the tube surface is computed.

Overrides:
computeDrawData3D in class SpaceCurve
Parameters:
view - the 3D View where the Exhibit is about to be drawn.
exhibitNeedsRedraw - if true, then something about the Exhibit has changed that probably requires recomputation of cached data. For example, this is set to true when one of the Parameters of the Exhibit has changed since the previous redraw.
previousTransform - the Transform3D that was used the last time this exhibit was drawn. This can be null, if this is the first time that the Exhibit is being drawn (in 3D).
newTransform - the transform that will be used to draw the Exhibit during the current drawing operation. This parameter and the previousTransform3D parameter are provided so that the Exhbit can detect those rare cases where cached data exists that depends on the transform. Most Exhibits will just ignore the transform parameters.

### doDraw3D

protected void doDraw3D(java.awt.Graphics2D g,
View3D view,
Transform3D transform)
Draws either a tube view or a regular curve view of this exhibit, depending on the type of View in which the curve is being rendered.

Overrides:
doDraw3D in class SpaceCurve
Parameters:
g - the graphics context where the exhibit is being drawn.
view - The View3D in which the exhibit is being drawn. In general, it is advisable to use the view for all drawing operations.
transform - The transform that is being used to draw the exhibit.