public class RouteWidget extends CurveWidget
A path interpolating start and end vertices.
The path may (immutably) be RouteWidget.RouteType.LINEAR
, RouteWidget.RouteType.MANHATTAN
, or RouteWidget.RouteType.BEZIER
.
Vertex array is one line strip of 2 (RouteWidget.RouteType.LINEAR
), 4 (RouteWidget.RouteType.MANHATTAN
) or ns
+1 (RouteWidget.RouteType.BEZIER
) C3_V
vertices.
Bezier implementation follows [Foley, van Dam, Feiner, Hughes. Computer Graphics: Principles and Practice. Second Edition in C. 1997. p. 489].
Copyright (C) 2008 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Modifier and Type | Class and Description |
---|---|
static class |
RouteWidget.RouteType
the possible route types
|
Modifier and Type | Field and Description |
---|---|
protected float[] |
bezierP2
internal Bezier vertices
|
protected float[] |
bezierP3
internal Bezier vertices
|
private static java.lang.String |
cvsid |
protected float[] |
dCoord
vector from
CurveWidget.startCoord to CurveWidget.endCoord |
static int |
DEF_NUM_BEZIER_SEGMENTS
default
ns for RouteWidget.RouteType.BEZIER |
protected float[] |
endTangent
RouteWidget.RouteType.BEZIER endpoint tangent vectors |
protected float[] |
lManhattan
accumulated manhattan lengths
|
int |
ns
number of segments
|
protected float[] |
startTangent
RouteWidget.RouteType.BEZIER endpoint tangent vectors |
protected float[] |
temp2V3
temp storage
|
RouteWidget.RouteType |
type
the type of this Route
|
appearance, DASHED_PATTERN, DEF_COLOR, DEF_END_COORD, DEF_START_COORD, DOTTED_PATTERN, endColor, endCoord, geometry, lineAttributes, ORIGIN, SOLID_PATTERN, startColor, startCoord, tempV3, trackLengthFactor, vertexBuffer, X, Y, Z
alpha, autoSetBoundingSpheres, boundingSphereCenter, boundingSphereCenterInView, boundingSphereRadius, boundingSphereRadiusInView, dbgEnabled, dbgNormalsGeometry, dbgNormalsVertices, dbgSpheresGeometry, dbgSpheresVertices, DEF_DBG_NORMAL_LENGTH, DEF_WIDGET_LENGTH, enabled, numGeometries, primitiveIterator, propertyMap, rx, vertexAccessor, widgetLength
Constructor and Description |
---|
RouteWidget()
Covers
RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[]) , uses default coords, num segments,
tangents, color, and type. |
RouteWidget(float[] startCoord,
float[] endCoord)
Covers
RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[]) , uses default num segments,
tangents, color, and type. |
RouteWidget(RouteWidget.RouteType type)
Covers
RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[]) , uses default coords, num segments,
tangents, and color. |
RouteWidget(RouteWidget.RouteType type,
float[] startCoord,
float[] endCoord)
Covers
RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[]) , uses default num segments,
tangents, and color. |
RouteWidget(RouteWidget.RouteType type,
float[] startCoord,
float[] endCoord,
float[] startColor,
float[] endColor)
Covers
RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[]) , uses default num segments and
tangents. |
RouteWidget(RouteWidget.RouteType type,
float[] startCoord,
float[] endCoord,
float[] startTangent,
float[] endTangent,
float[] startColor,
float[] endColor)
Covers
RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[]) , uses default num segments. |
RouteWidget(RouteWidget.RouteType type,
int numSegments,
float[] startCoord,
float[] endCoord)
Covers
RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[]) , uses default tangents and color. |
RouteWidget(RouteWidget.RouteType type,
int numSegments,
float[] startCoord,
float[] endCoord,
float[] startTangent,
float[] endTangent,
float[] startColor,
float[] endColor)
Creates a new RouteWidget from startCoord to endCoord.
|
Modifier and Type | Method and Description |
---|---|
protected float |
distanceSquared(float[] a,
float[] b)
compute squared Euclidean distance from a to b
|
void |
dump()
dump(PrintStream) to System.out |
void |
dump(java.io.PrintStream s)
dump state
|
protected void |
endDiffChanged(float... diffCoord)
this impl updates bezier and manhattan state
|
protected void |
extentsChanged(boolean startDiffers,
boolean endDiffers)
this impl updates bezier and manhattan state
|
float |
getEndTangentLength()
get the length of the end tangent
|
float |
getStartTangentLength()
get the length of the start tangent
|
protected float[] |
interpolateBezierPosition(float t,
int start,
float[] position)
see class header doc
|
protected float[] |
interpolateBezierTangent(float t,
int start,
float[] tangent)
see class header doc
|
float[] |
interpolateColor(float t)
Covers
interpolateColor(float, int, float[]) , conses and
starts at 0. |
float[] |
interpolateColor(float t,
float[] color)
covers
interpolateColor(float, int, float[]) , starts at 0 |
float[] |
interpolateColor(float t,
int start,
float[] color)
Compute the color at a point along the route.
|
float[] |
interpolatePosition(float t)
Covers
interpolatePosition(float, int, float[]) , conses and
starts at 0. |
float[] |
interpolatePosition(float t,
float[] position)
covers
interpolatePosition(float, int, float[]) , starts at 0 |
float[] |
interpolatePosition(float t,
int start,
float[] position)
Compute the coordinates of a point along the route.
|
float[] |
interpolateTangent(float t)
Covers
interpolateTangent(float, int, float[]) , conses and
starts at 0. |
float[] |
interpolateTangent(float t,
float[] tangent)
covers
interpolateTangent(float, int, float[]) , starts at 0 |
float[] |
interpolateTangent(float t,
int start,
float[] tangent)
Compute the tangent at a point along the route.
|
protected void |
lengthChanged(float length,
float dx,
float dy,
float dz)
this impl updates bezier and manhattan state
|
protected static int |
numSegments(RouteWidget.RouteType type,
int numSegments)
compute the implied number of line strip segments
|
void |
recomputeBoundingSpheres()
recompute the geometric bounding sphere
|
boolean |
setEndTangent(float... endTangent)
covers
setTangents(float[], float[]) , only sets end tangent |
boolean |
setEndTangentLength(float length)
covers
setTangentLengths(float, float) , only sets end tangent length |
boolean |
setStartTangent(float... startTangent)
covers
setTangents(float[], float[]) , only sets start tangent |
boolean |
setStartTangentLength(float length)
covers
setTangentLengths(float, float) , only sets start tangent length |
boolean |
setTangentLength(float length)
covers
setTangentLengths(float, float) , sets both tangent lengths |
boolean |
setTangentLengths(float startLength,
float endLength)
Re-scale one or both tangent vectors to the given length(s).
|
boolean |
setTangents(float[] startTangent,
float[] endTangent)
Update the terminal tangents.
|
protected void |
update()
recompute coords, colors, and
recomputeBoundingSpheres() |
different, isDegenerate, recomputeBoundingSphere, setColor, setColor, setColors, setColors, setEnd, setEndColor, setEndColor, setEndDiff, setExtents, setLength, setLinePattern, setLinePattern, setLineWidth, setStart, setStartColor, setStartColor, trackWidgetLength, widgetLengthChanged
cons, countGeometryArrays, disableBoundingSphere, disableBoundingSpheres, enableDBGGeometry, enableGeometry, ensureBoundingSpheresInView, getAppearance, getBoundingSphereCenter, getBoundingSphereRadius, getGeometry, getProperty, getWidget, getWidgetAlpha, hasBoundingSphere, hasBoundingSphereInView, hasProperty, indexOf, populateFrom, recomputeBoundingSphere, removeDBGNormals, removeDBGSpheres, removeGeometry, removeGeometry, removeProperty, replaceAppearanceWithClone, replaceGeometryWithClone, scaleWidget, setAppearance, setBoundingSphereCenter, setBoundingSphereRadius, setGeometry, setGeometryAlpha, setGeometryAlpha, setGeometryAndAppearance, setProperty, setProperty, setWidgetAlpha, setWidgetLength, updateAllDBGNormals, updateAllDBGNormals, updateAllDBGSpheres, updateDBGNormals, updateDBGNormals, updateDBGSpheres, updateExistingDBGNormals, updateExistingDBGSpheres
private static final java.lang.String cvsid
public static final int DEF_NUM_BEZIER_SEGMENTS
ns
for RouteWidget.RouteType.BEZIER
public final int ns
protected final float[] bezierP2
protected final float[] bezierP3
protected final float[] dCoord
CurveWidget.startCoord
to CurveWidget.endCoord
protected final float[] lManhattan
protected final float[] startTangent
RouteWidget.RouteType.BEZIER
endpoint tangent vectorsprotected final float[] endTangent
RouteWidget.RouteType.BEZIER
endpoint tangent vectorsprotected final float[] temp2V3
public final RouteWidget.RouteType type
public RouteWidget(RouteWidget.RouteType type, int numSegments, float[] startCoord, float[] endCoord, float[] startTangent, float[] endTangent, float[] startColor, float[] endColor)
Creates a new RouteWidget from startCoord to endCoord.
type
- the route type, or null for the default RouteWidget.RouteType.LINEAR
numSegments
- the number of segments, applies only to RouteWidget.RouteType.BEZIER
routes, or non-positive to use DEF_NUM_BEZIER_SEGMENTS
startCoord
- the coordinates of the start vertex, or null to use
CurveWidget.DEF_START_COORD
endCoord
- the coordinates of the end vertex, or null to use CurveWidget.DEF_END_COORD
startTangent
- start tangent vector, applies only to RouteWidget.RouteType.BEZIER
routes, null to use (0, 0, 0)endTangent
- start tangent vector, applies only to RouteWidget.RouteType.BEZIER
routes, null to use (0, 0, 0)startColor
- the color at the start vertex, or null to use CurveWidget.DEF_COLOR
endColor
- the color at the end vertex, or null to use CurveWidget.DEF_COLOR
public RouteWidget(RouteWidget.RouteType type, float[] startCoord, float[] endCoord, float[] startTangent, float[] endTangent, float[] startColor, float[] endColor)
Covers RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[])
, uses default num segments.
public RouteWidget(RouteWidget.RouteType type, float[] startCoord, float[] endCoord, float[] startColor, float[] endColor)
Covers RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[])
, uses default num segments and
tangents.
public RouteWidget(RouteWidget.RouteType type, int numSegments, float[] startCoord, float[] endCoord)
Covers RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[])
, uses default tangents and color.
public RouteWidget(RouteWidget.RouteType type, float[] startCoord, float[] endCoord)
Covers RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[])
, uses default num segments,
tangents, and color.
public RouteWidget(float[] startCoord, float[] endCoord)
Covers RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[])
, uses default num segments,
tangents, color, and type.
public RouteWidget(RouteWidget.RouteType type)
Covers RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[])
, uses default coords, num segments,
tangents, and color.
public RouteWidget()
Covers RouteWidget(RouteType, int, float[], float[], float[],
float[], float[], float[])
, uses default coords, num segments,
tangents, color, and type.
protected static int numSegments(RouteWidget.RouteType type, int numSegments)
protected void extentsChanged(boolean startDiffers, boolean endDiffers)
extentsChanged
in class CurveWidget
protected void endDiffChanged(float... diffCoord)
endDiffChanged
in class CurveWidget
protected void lengthChanged(float length, float dx, float dy, float dz)
lengthChanged
in class CurveWidget
public boolean setTangents(float[] startTangent, float[] endTangent)
Update the terminal tangents.
Has no effect if this is not a RouteWidget.RouteType.BEZIER
route.
startTangent
- the new start tangent, or null to keep currentendTangent
- the new end tangent, or null to keep currentpublic boolean setStartTangent(float... startTangent)
setTangents(float[], float[])
, only sets start tangentpublic boolean setEndTangent(float... endTangent)
setTangents(float[], float[])
, only sets end tangentpublic boolean setTangentLengths(float startLength, float endLength)
Re-scale one or both tangent vectors to the given length(s).
Has no effect if this is not a RouteWidget.RouteType.BEZIER
route.
startLength
- the new length for the start vertex tangent, or NaN to
leave unchangedendLength
- the new length for the end vertex tangent, or NaN to
leave unchangedpublic boolean setStartTangentLength(float length)
setTangentLengths(float, float)
, only sets start tangent lengthpublic boolean setEndTangentLength(float length)
setTangentLengths(float, float)
, only sets end tangent lengthpublic boolean setTangentLength(float length)
setTangentLengths(float, float)
, sets both tangent lengthspublic float getStartTangentLength()
public float getEndTangentLength()
public float[] interpolatePosition(float t, int start, float[] position)
Compute the coordinates of a point along the route.
t
- the position of the point in the range [0.0, 1.0]public float[] interpolatePosition(float t, float[] position)
interpolatePosition(float, int, float[])
, starts at 0public float[] interpolatePosition(float t)
Covers interpolatePosition(float, int, float[])
, conses and
starts at 0.
public float[] interpolateTangent(float t, int start, float[] tangent)
Compute the tangent at a point along the route.
t
- the position of the tangent in the range [0.0, 1.0]public float[] interpolateTangent(float t, float[] tangent)
interpolateTangent(float, int, float[])
, starts at 0public float[] interpolateTangent(float t)
Covers interpolateTangent(float, int, float[])
, conses and
starts at 0.
public float[] interpolateColor(float t, int start, float[] color)
Compute the color at a point along the route.
t
- the position of the color in the range [0.0, 1.0]public float[] interpolateColor(float t, float[] color)
interpolateColor(float, int, float[])
, starts at 0public float[] interpolateColor(float t)
Covers interpolateColor(float, int, float[])
, conses and
starts at 0.
public void dump()
dump(PrintStream)
to System.outprotected void update()
recomputeBoundingSpheres()
update
in class CurveWidget
public void recomputeBoundingSpheres()
recomputeBoundingSpheres
in class CurveWidget
protected float distanceSquared(float[] a, float[] b)
protected float[] interpolateBezierPosition(float t, int start, float[] position)
protected float[] interpolateBezierTangent(float t, int start, float[] tangent)