|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.architecture.traffic.util.CurveUtils
public class CurveUtils
This class presents methods to handle curves
| Constructor Summary | |
|---|---|
CurveUtils()
|
|
| Method Summary | |
|---|---|
static java.awt.Point |
calcIntersect(java.awt.Point p1,
java.awt.Point p2,
double ar1,
double ar2)
Calculate the intersection coordinats for two lines, given a base point and angle for each line. |
static double |
calcLength(TurnCurve c,
int step)
Calculates the length of the specified curve in steps of size step |
static int |
calcPathSteps(TurnCurve c)
Returns the number of steps used to traverse the specified curve |
static TurnCurve |
createCurve(java.awt.Point p1,
java.awt.Point p2,
double a1,
double a2)
|
static java.awt.geom.GeneralPath |
createPath(TurnCurve c1,
TurnCurve c2)
Creates a QCurve given two points and angles |
static double |
getAngle(TurnCurve c,
int index,
int step)
Returns the angle of a given curve at the given index |
static double |
getCurrentAngle(TurnCurve c,
java.awt.Point p)
|
static java.awt.Point |
getPoint(TurnCurve c,
int index,
int step)
Returns the coordinates of the point with specified index and stepsize on a given curve |
static int |
getRoadLength(Road road,
int step)
Returns the length of a given Road. |
static double |
normalize(double a)
Convert any angle to a value in the range [0, 2Pi] |
static void |
setupRoadSizes(Road road,
int step)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CurveUtils()
| Method Detail |
|---|
public static java.awt.Point calcIntersect(java.awt.Point p1,
java.awt.Point p2,
double ar1,
double ar2)
throws CurveException
p1 - The base point for the first linep2 - The base point for the second linear1 - The angle of the first line in radiansar2 - The angle of the second line in radians
CurveException
public static TurnCurve createCurve(java.awt.Point p1,
java.awt.Point p2,
double a1,
double a2)
throws CurveException
CurveException
public static java.awt.geom.GeneralPath createPath(TurnCurve c1,
TurnCurve c2)
p1 - The coordinats of the first pointp2 - The coordinats of the second pointa1 - The angle of the first point in radiansa2 - The angle of the second point
public static QCurve createCurve(Point p1, Point p2, double a1, double a2) throws CurveException
{
Point tp = new Point((int)(p1.x + p1.distance(p2) * Math.cos(a1)),(int)(p1.y - p1.distance(p2) * Math.sin(a1)));
Rectangle r = new Rectangle(p2.x - 10, p2.y - 10, 20, 20);
Point ip;
if(r.contains(tp))
return new QCurve(p1,p2);
ip = calcIntersect(p1,p2,a1,a2);
QCurve c = new QCurve(p1,ip,p2);
// test voor path-iterator-bug:
Point2D.Double p = c.next(c.getFirst(),2);
if(!(c.getBounds().contains(p)))
{
c = new QCurve(p2,ip,p1);
p = c.next(c.getFirst(),2);
c.setSwitched(true);
}
return c;
}
/**
Creates a GeneralPath connecting both curves in a Drivelane-like fashionc1 - The first curvec2 - The second curve
public static double calcLength(TurnCurve c,
int step)
c - The QCurve whose length to calculatestep - The stepsize
public static int calcPathSteps(TurnCurve c)
c - The QCurve
public static java.awt.Point getPoint(TurnCurve c,
int index,
int step)
c - The curvestep - The stepsizeindex - The index of the point
public static double getAngle(TurnCurve c,
int index,
int step)
c - The curvestep - The stepsizeindex - The index
public static double getCurrentAngle(TurnCurve c,
java.awt.Point p)
public static double normalize(double a)
public static void setupRoadSizes(Road road,
int step)
throws InfraException
InfraException
public static int getRoadLength(Road road,
int step)
throws InfraException
road - A Roadstep - The step-size in pixels
InfraException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||