jbotrace.base
Class Straight

java.lang.Object
  |
  +--jbotrace.base.Segment
        |
        +--jbotrace.base.Straight

public class Straight
extends Segment

Description: Represent a straight in the track.


Field Summary
 
Fields inherited from class jbotrace.base.Segment
CURVE, STRAIGHT
 
Constructor Summary
Straight(Line line, double startWidth, double endWidth)
          Creates a new straight with the given points: 0 and 1 build the first line, 2 and 3 the second.
 
Method Summary
 Vec[] getBoundingBox()
          Returns the upper left and lower right corners of a bow bounding the segment
 Vec[] getCorners()
          Returns the four edges of the quad.
 double getDirection()
          Returns the direction of the straight
 double getDistanceToEnd(Vec pos)
          Returns the distance to the end of the straight from the given position
 double getDistanceToLeft(Vec pos)
          Returns the distance to the left side of the straight at the given position
 double getDistanceToMiddle(Vec pos)
          Returns the distance to the middle of the track
 double getDistanceToRight(Vec pos)
          Returns the distance to the right side of the straight at the given position
 double getDistanceToSide(Vec pos)
          Returns the distance of the given point to the side of the track or the maximum value for double, if the point is not beside the straight
 double getEndWidth()
          Returns the width at the end of the track part.
 double getLength()
          Returns the length of the straight
 Vec getMiddle()
          Returns the middle of the part
 Vec[] getPoints()
          Returns the array of points that build the straight
 double getRadius()
          This it a straight, we return 0.
 double getStartWidth()
          Returns the width at the start of the track part
 int getType()
          Returns the type number of the segment.
 Vec getVector()
          Returns a vector in the direction and with the lenght of the straight.
 double getWidth(Vec pos)
          Return the width of the curve at the given position
 boolean isOnSegment(Vec pos)
          Returns true if the given position is on the part and false otherwise.
 void move(Vec moveVec)
          Moves the segment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Straight

public Straight(Line line,
                double startWidth,
                double endWidth)
Creates a new straight with the given points: 0 and 1 build the first line, 2 and 3 the second. The lower numbered points mark the start of the part.

Method Detail

isOnSegment

public boolean isOnSegment(Vec pos)
Returns true if the given position is on the part and false otherwise.

Specified by:
isOnSegment in class Segment

getBoundingBox

public Vec[] getBoundingBox()
Returns the upper left and lower right corners of a bow bounding the segment

Specified by:
getBoundingBox in class Segment

getCorners

public Vec[] getCorners()
Returns the four edges of the quad.


getDirection

public double getDirection()
Returns the direction of the straight


getDistanceToEnd

public double getDistanceToEnd(Vec pos)
Returns the distance to the end of the straight from the given position

Specified by:
getDistanceToEnd in class Segment

getDistanceToLeft

public double getDistanceToLeft(Vec pos)
Returns the distance to the left side of the straight at the given position

Specified by:
getDistanceToLeft in class Segment

getDistanceToMiddle

public double getDistanceToMiddle(Vec pos)
Returns the distance to the middle of the track

Specified by:
getDistanceToMiddle in class Segment

getDistanceToRight

public double getDistanceToRight(Vec pos)
Returns the distance to the right side of the straight at the given position

Specified by:
getDistanceToRight in class Segment

getDistanceToSide

public double getDistanceToSide(Vec pos)
Returns the distance of the given point to the side of the track or the maximum value for double, if the point is not beside the straight

Specified by:
getDistanceToSide in class Segment

getEndWidth

public double getEndWidth()
Returns the width at the end of the track part.

Specified by:
getEndWidth in class Segment

getLength

public double getLength()
Returns the length of the straight

Specified by:
getLength in class Segment

getMiddle

public Vec getMiddle()
Returns the middle of the part

Specified by:
getMiddle in class Segment

getRadius

public double getRadius()
This it a straight, we return 0.

Specified by:
getRadius in class Segment

getType

public int getType()
Returns the type number of the segment.

Specified by:
getType in class Segment

getPoints

public Vec[] getPoints()
Returns the array of points that build the straight


getStartWidth

public double getStartWidth()
Returns the width at the start of the track part

Specified by:
getStartWidth in class Segment

getVector

public Vec getVector()
Returns a vector in the direction and with the lenght of the straight.


getWidth

public double getWidth(Vec pos)
Return the width of the curve at the given position


move

public void move(Vec moveVec)
Moves the segment

Overrides:
move in class Segment