vmm.planecurve.parametric
Class PlaneCurveParametric

java.lang.Object
  extended by vmm.core.Exhibit
      extended by vmm.planecurve.PlaneCurve
          extended by vmm.planecurve.parametric.PlaneCurveParametric
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
ArchimedeanSpiral, Catenary, ConicSection, DecoratedCurve, Folium, Limacon, Lissajous, Logarithmicspiral, Nephroid, NephroidOfFreeth, UserPlaneCurveParametric, UserPlaneCurveParametricKappa, UserPlaneCurveParametricPolar

public abstract class PlaneCurveParametric
extends PlaneCurve

A curve in the plane that is defined by differentiable functions x(t) and y(t).


Nested Class Summary
static class PlaneCurveParametric.PlaneCurveParametricView
          Defines the default View of a PlaneCurveParametric.
 
Field Summary
protected  RealParam tmax
          The maximum value of t for points on the curve.
protected  RealParam tmin
          The minimum valur of t for points on the curve.
protected  IntegerParam tResolution
          The number of t-values for points on the curve.
protected  double[] tVals
          The t-values used to compute the points (x(t),y(t)) on the curve.
 
Fields inherited from class vmm.planecurve.PlaneCurve
movingSquare, points, randomSquare
 
Fields inherited from class vmm.core.Exhibit
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform
 
Constructor Summary
PlaneCurveParametric()
          Construct a plane curve with Parameters tmin, tmax, and tResolution.
 
Method Summary
 void doDraw(java.awt.Graphics2D g, View view, Transform transform)
          Draw the curve in a specified View.
 ActionList getActionsForView(View view)
          Returns a list of actions that can be applied to a PlaneCurveParametric.
 Animation getCreateAnimation(View view)
          Returns an animation that shows the curve being drawn bit-by-bit.
 View getDefaultView()
          Returns a new instance of the nested class PlaneCurveParametric.PlaneCurveParametricView.
 double getT(int index)
          Return the t-value for one of the points on the curve.
 int getTResolution()
          Returns the number of intervals into which the curve is divided.
protected  void makePoints()
          Calcululates the array of points for this curve using the functions xValue(double) and yValue(double) to compute the points at equally spaced t-values between tmin and tmax.
 java.awt.geom.Point2D[] myCircle(double mx, double my, double rad, int numPoints)
          parametrized circle to draw circle arcs in different colors.
 double x2ndDerivativeValue(double t)
          Computes x''(t) for a given value of t.
 double xDerivativeValue(double t)
          Computes x'(t) for a given value of t.
abstract  double xValue(double t)
          Computes x(t) for a given value of t.
 double y2ndDerivativeValue(double t)
          Computes y''(t) for a given value of t.
 double yDerivativeValue(double t)
          Computes y'(t) for a given value of t.
abstract  double yValue(double t)
          Computes y(t) for a given value of t.
 
Methods inherited from class vmm.planecurve.PlaneCurve
computeDrawData, fillRandomSquare, getPoint, getPointCount, initializeMovingSquare, moveSquare
 
Methods inherited from class vmm.core.Exhibit
addChangeListener, addDecoration, addExtraXML, addParameter, addView, clearDecorations, computeDrawDataHook, doDrawHook, fireExhibitChangeEvent, forceRedraw, getAdditionalAnimationsForView, getAlternativeViews, getBuildAnimation, getDecorations, getDefaultBackground, getDefaultForeground, getDefaultTransform, 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)) 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.


tmin

protected RealParam tmin
The minimum valur of t for points on the curve.


tmax

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


tVals

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

Constructor Detail

PlaneCurveParametric

public PlaneCurveParametric()
Construct a plane curve with Parameters tmin, tmax, and tResolution. The curve will be defined by the functions xValue and yValue in a concrete subclass.

Method Detail

xValue

public abstract double xValue(double t)
Computes x(t) for a given value of t.


yValue

public abstract double yValue(double t)
Computes y(t) for a given value of t.


xDerivativeValue

public double xDerivativeValue(double t)
Computes x'(t) for a given value of t. The default version defined in this class computes an approximate value numerically, using values of the function itself at points near t.


yDerivativeValue

public double yDerivativeValue(double t)
Computes y'(t) for a given value of t. The default version defined in this class computes an approximate value numerically, using values of the function itself at points near t.


x2ndDerivativeValue

public double x2ndDerivativeValue(double t)
Computes x''(t) for a given value of t. The default version defined in this class computes an approximate value numerically, using values of the function itself at points near t.


y2ndDerivativeValue

public double y2ndDerivativeValue(double t)
Computes y''(t) for a given value of t. The default version defined in this class computes an approximate value numerically, using values of the function itself at points near t.


getTResolution

public int getTResolution()
Returns the number of intervals into which the curve is divided. Note that the number of points that are drawn on the curve is one more than the tResolution.


getT

public double getT(int index)
Return the t-value for one of the points on the curve. The number of points is getTResolution() + 1, and they are numbered from 0 to getTResolution(). If this method is called before the curve has been drawn, the return value will be Double.NaN. The return value is also Double.NaN if the specified index is not in the range 0 to getTResolution(), inclusive. The corresponding point on the curve can be obtained by calling xValue() and yValue()

The value returned by this method is only valid after the curve has been drawn; if it is called before that time, the return value will be Double.NaN.

Parameters:
index - A position in the array of t-values that specifies which t-value shoud be returned.
See Also:
getTResolution(), xValue(double), yValue(double)

myCircle

public java.awt.geom.Point2D[] myCircle(double mx,
                                        double my,
                                        double rad,
                                        int numPoints)
parametrized circle to draw circle arcs in different colors.


makePoints

protected void makePoints()
Calcululates the array of points for this curve using the functions xValue(double) and yValue(double) to compute the points at equally spaced t-values between tmin and tmax. The number of points is one plus the value of tResolution.

Specified by:
makePoints in class PlaneCurve

doDraw

public void doDraw(java.awt.Graphics2D g,
                   View view,
                   Transform transform)
Draw the curve in a specified View. If the View belogs to the nested class PlaneCurveParametric.PlaneCurveParametricView (which is the default), then only a fraction of the curve might be drawn, as specified in the View; this feature is used in the creation animation for the curve.

Overrides:
doDraw in class PlaneCurve
Parameters:
g - The graphics context where the Exhibit is being drawn. It has already been cleared to the background color (assuming that drawing is being done in the usual way, as defined in the top-level View class).
view - The View that is drawing the Exhibit; this object contains other information that might be of use, such as the Display, if any, associated with the View.
transform - Contains information about the rectangular area in the xy-plane that is being drawn and about the rectangle of pixels in the graphics context where it is drawn. Note that at least for the top-level View class, transform.getX() and transform.getY() can be assumed to be zero.
See Also:
Exhibit.render(Graphics2D, View, Transform, ArrayList), Exhibit.computeDrawData(View, boolean, Transform, Transform)

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 PlaneCurveParametric.PlaneCurveParametricView, then the return value is null.
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.

getDefaultView

public View getDefaultView()
Returns a new instance of the nested class PlaneCurveParametric.PlaneCurveParametricView.

Overrides:
getDefaultView in class Exhibit

getActionsForView

public ActionList getActionsForView(View view)
Returns a list of actions that can be applied to a PlaneCurveParametric. This adds a separator and four actions that run various animations to the list obtained from super.getActionsForView(view).

Overrides:
getActionsForView in class Exhibit
Parameters:
view - The view for which the actions should apply. If this is null, then no new actions are added to those inherited from the superclass.