|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface IBezier
An object that implements a curved band, where the centre line is defined by a 4-point (cubic) bezier curve, and there are two edges which may be at a uniform width or may change linearly from the start width to the end width.
The four control points are labelled p[0], p[1], p[2] and p[3]. The curve has an implied direction, going from p[0] to p[3], but it can be used as the centreline for network objects allowing two-way travel.
The Bezier curve is drawn using a variable number, N, of intermediate points, and these in turn define N-1 straight line segments. N increases with the "curviness" of the line. There is a global parameter for maximum curve resolution which can be reduced to restrict the memory used to store intermediate bezier points.
The control points define the centre line, and two IEdge objects defining the outer edges. The distance of the edges from the centre line is defined by two width values, one at the start, and one at the end. If the widths are different, the width will change at a uniform rate along the length of the curve. This can lead to some unexpected outcomes for curvy curves.
| Field Summary | |
|---|---|
static double |
DRAW_ALL
Use this as the partFill parameter to fill(IDrawing, int, double)
to draw the whole length of the curve |
| Method Summary | |
|---|---|
void |
addRecalcListener(IRecalcListener rc)
Add a listener who will be notified when the shape of the bezier changes - when any of the control points move |
IAngle |
angleEnd()
Returns the bearing angle, relative to North, from point p[2] to point p[3] |
IAngle |
angleStart()
Returns the bearing angle, relative to North, from point p[0] towards p[1] |
IBezierAssociate |
associate()
A reference to the network object that uses this bezier. |
IAngle |
bearing(int pi,
int pj)
Returns the bearing angle (relative to North) of control point J from control point I. |
ICentre |
centre()
The centre point, valid only if this bezier is an arc |
boolean |
closerThan(IBezier that,
double gap)
Returns true if beziers pass closer than given gap (for turn conflicts etc) |
boolean |
crosses(IBezier that)
Returns true if this Bezier crosses that one |
void |
draw(IDrawing drw,
boolean force,
double dz,
double width,
int rgbSpecial,
int arrowDirection,
boolean drawDashed,
boolean hideHandles,
boolean drawBarred)
Draw this bezier, with a range of parameters to control the line style, colour, arrows etc. |
IXyz |
edgePt(int ti,
double sign)
Returns a point on the edge, given the internal point index and a -1 or +1 for left or right respectively |
void |
fill(IDrawing drw,
int rgb,
double partFill)
Draw this bezier curve, filling the area from edge to edge. |
double |
halfWidth(double distance)
Returns the half-width at the given distance |
double |
halfWidthE()
Returns the half-width at the End of the curve |
double |
halfWidthS()
Returns the half-width at the Start of the curve |
boolean |
isArc()
Returns true if this bezier is currently a circular arc, with an associated ICentre point |
boolean |
isArcLeft()
Returns true if this arced bezier turns to the left going from p[0] to p[3] |
boolean |
isFree()
Returns true if the bezier is curved, i.e. |
boolean |
isStraight()
Returns true if the bezier is currently straight, and control points p[1] and p[2] are not shown |
double |
length()
Returns the length of the centreline, calculated as the sum of all the internal straight line segment distances. |
IUndoable |
moveP(int pi,
IXyz move)
Move the given point [0..3] BY the given move vector |
int |
n()
The number of points in the curve |
IXyz |
nearest(IXyz point)
Returns the nearest point on the bezier to the given point |
double |
nearest(IXyz pointP,
IXyz resultQ,
boolean fromStart)
Find the nearest point, Q, on the curve to a given point P, which can be anywhere, and return that point and the distance of that point along the bezier. |
void |
outline(IDrawing drw,
int rgb,
double lineWidth)
Draw the outline of the bezier, in the given colour and width |
IXyz |
p(int i)
Return a control point where i = 0..3 |
void |
p(int i,
IXyz pnew)
Move one of the control points [0..3] to the new position |
IPathway |
pathway(boolean forward)
Returns the IPathway object associated with the given direction on this bezier. |
IPosition |
position(double distanceFromStart)
Returns a newly-created object containing {point, bearing, gradient} at the given distance along the bezier curve |
IXyz |
pt(int i)
A point in the curve, use n() for number of points |
void |
recalc()
Force the internal points to be recalculated |
boolean |
selected()
Returns true if the bezier is currently selected in the GUI |
void |
sideShift(IUndoStack us,
double d)
Move the bezier to the side away from the median by distance 'd'. |
void |
smooth()
Smooth the curve to attempt to make it tangential to any connected curves or straight lines |
void |
stretch(IUndoStack us,
boolean atP3,
double stretchBy)
Stretch the bezier by the given length. |
double |
width(double distance)
Returns the width at the given distance |
double |
widthE()
Returns the width at the End of the curve |
double |
widthS()
Returns the width at the Start of the curve |
| Field Detail |
|---|
static final double DRAW_ALL
fill(IDrawing, int, double)
to draw the whole length of the curve
| Method Detail |
|---|
IXyz p(int i)
void p(int i,
IXyz pnew)
int n()
IXyz pt(int i)
IUndoable moveP(int pi,
IXyz move)
void sideShift(IUndoStack us,
double d)
void stretch(IUndoStack us,
boolean atP3,
double stretchBy)
atP3 - if true, the bezier is stretched at the end, at p[3] otherwise it is stretched at the start, at p[0]boolean isFree()
boolean isStraight()
boolean isArc()
boolean isArcLeft()
boolean selected()
void addRecalcListener(IRecalcListener rc)
ICentre centre()
IBezierAssociate associate()
IPosition position(double distanceFromStart)
void recalc()
void smooth()
IXyz nearest(IXyz point)
boolean closerThan(IBezier that,
double gap)
boolean crosses(IBezier that)
double nearest(IXyz pointP,
IXyz resultQ,
boolean fromStart)
pointP - [IN] a given point, P, not on the curveresultQ - [OUT] another point Q, the nearest point on the curve to PfromStart - set to true if the return distance is from the start of the curve, false if the distance is from the endIPathway pathway(boolean forward)
IAngle bearing(int pi,
int pj)
double length()
double halfWidthS()
double halfWidthE()
double halfWidth(double distance)
double widthS()
double widthE()
double width(double distance)
IAngle angleStart()
IAngle angleEnd()
IXyz edgePt(int ti,
double sign)
ti - the index of the point, [0..N-1]sign - either -1 for the "kerb" edge or +1 for the "median" edge. This side parameter also applies to walkways, but means the same side as for a lane. That is, if it were
used for a footpath, to the left of a road, where traffic drives on the left, then it could be argued that the kerb side was the right side, but this is not the case in Commuter.
void draw(IDrawing drw,
boolean force,
double dz,
double width,
int rgbSpecial,
int arrowDirection,
boolean drawDashed,
boolean hideHandles,
boolean drawBarred)
drw - The Drawing handleforce - Force this line to be drawn, regardless of any related Viewable/Aspect statesdz - Translate the line by "dz" in the z-axis. This is a convenience to "lift" the line above the corresponding surfacewidth - the line widthrgbSpecial - an RGB colour to override the colour from the associated Viewable/AspectarrowDirection - -1 or +1 to draw an arrow, as for turns/ signals. zero means no arrowdrawDashed - The dash length is pre-defined and cannot be changed herehideHandles - drawBarred - Draws a "T" as in for example when a traffic signal is at red.
void fill(IDrawing drw,
int rgb,
double partFill)
drw - The drawing handlergb - THE RGB colour code to usepartFill - set partFill to DRAW_ALL (1.0) to draw entire length of curve
void outline(IDrawing drw,
int rgb,
double lineWidth)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||