maspack.geometry
Class NURBSCurve3d

java.lang.Object
  extended by maspack.geometry.NURBSObject
      extended by maspack.geometry.NURBSCurveBase
          extended by maspack.geometry.NURBSCurve3d
All Implemented Interfaces:
GLRenderable, GLSelectable, HasRenderProps, Renderable

public class NURBSCurve3d
extends NURBSCurveBase

Implements a NURBS curve


Field Summary
 
Fields inherited from class maspack.geometry.NURBSCurveBase
CLOSED, init, OPEN
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Constructor Summary
NURBSCurve3d()
          Creates an empty NURBS curve.
NURBSCurve3d(int d, int type, Vector4d[] ctrlPnts, double[] knots)
          Creates an open or closed NURBS curve with a specified degree, knots, and control points.
 
Method Summary
 void eval(Point3d pnt, double u)
          Evaluates the point on this curve for parameter u.
 Point3d[] evalPoints(int npnts)
          Returns a set of points evaluated along the curve at intervals which are evenly spaced with respect to the curve parameter.
 double findPoint(Point3d pnt, double umin, double umax)
          Finds a u value for a given curve point within a specified interval of the curve.
 void set(NURBSCurve3d curve)
           
 
Methods inherited from class maspack.geometry.NURBSCurveBase
addControlPoint, computeControlPolygonLength, convertToBezier, createRenderProps, createUniformKnots, getDegree, getKnot, getKnotIndex, getKnots, getRange, getResolution, getType, insertKnot, isBezier, isBSpline, isClosed, numKnots, read, read, removeControlPoint, render, reset, set, set, set, setBezier, setCircle, setRange, setResolution, setUniformCubic, write, write
 
Methods inherited from class maspack.geometry.NURBSObject
controlPointIsSelected, getControlPoint, getControlPoints, getDrawControlShape, getLineWidth, getObjToWorld, getObjToWorld, getPointSize, getRenderHints, getRenderProps, getSelection, isSelectable, numControlPoints, numSelectionQueriesNeeded, prerender, render, selectControlPoint, setDrawControlShape, setLineWidth, setObjToWorld, setPointSize, setRenderProps, transform, updateBounds, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NURBSCurve3d

public NURBSCurve3d()
Creates an empty NURBS curve.


NURBSCurve3d

public NURBSCurve3d(int d,
                    int type,
                    Vector4d[] ctrlPnts,
                    double[] knots)
Creates an open or closed NURBS curve with a specified degree, knots, and control points. For more information on these arguments, see set.

Parameters:
d - degree of the curve
type - curve type, which must be either OPEN or CLOSED.
ctrlPnts - control points
knots - knot values
Throws:
java.lang.IllegalArgumentException - if constraints on the arguments are violated
See Also:
NURBSCurveBase.set(int,int,Vector4d[],double[])
Method Detail

evalPoints

public Point3d[] evalPoints(int npnts)
Returns a set of points evaluated along the curve at intervals which are evenly spaced with respect to the curve parameter.

Parameters:
npnts - number of points to create
Returns:
array of evaluated points

eval

public void eval(Point3d pnt,
                 double u)
Evaluates the point on this curve for parameter u. If necessary, u is clipped to the range [ustart, uend].

Specified by:
eval in class NURBSCurveBase
Parameters:
pnt - returns the curve point value
u - curve parameter value

findPoint

public double findPoint(Point3d pnt,
                        double umin,
                        double umax)
Finds a u value for a given curve point within a specified interval of the curve. If the point is not actually on the specified interval, this routine attempts to return the u value for the nearest curve point. It should be noted that one point may correspond to multiple u values.

This routine uses an iterative golden section search, and so is not particularly fast.

Parameters:
pnt - point to search for
umin - minimum u valu for the interval
umax - maximum u valu for the interval
Returns:
u value for the point closest to pnt within the interval.

set

public void set(NURBSCurve3d curve)