Line Class Reference

#include <Geometry.h>


Public Member Functions

 Line (double a, double b, double c)
void show (ostream &os=cout)
VecPosition getIntersection (Line line)
int getCircleIntersectionPoints (Circle circle, VecPosition *posSolution1, VecPosition *posSolution2)
Line getTangentLine (VecPosition pos)
VecPosition getPointOnLineClosestTo (VecPosition pos)
double getDistanceWithPoint (VecPosition pos)
bool isInBetween (VecPosition pos, VecPosition point1, VecPosition point2)
double getYGivenX (double x)
double getXGivenY (double y)
double getACoefficient () const
double getBCoefficient () const
double getCCoefficient () const

Static Public Member Functions

static Line makeLineFromTwoPoints (VecPosition pos1, VecPosition pos2)
static Line makeLineFromPositionAndAngle (VecPosition vec, AngDeg angle)

Private Attributes

double m_a
double m_b
double m_c

Friends

ostream & operator<< (ostream &os, Line l)


Detailed Description

This class contains the representation of a line. A line is defined by the formula ay + bx + c = 0. The coefficients a, b and c are stored and used in the calculations.

Definition at line 273 of file Geometry.h.


Constructor & Destructor Documentation

Line::Line ( double  dA,
double  dB,
double  dC 
)

This constructor creates a line by given the three coefficents of the line. A line is specified by the formula ay + bx + c = 0.

Parameters:
dA a coefficients of the line
dB b coefficients of the line
dC c coefficients of the line

Definition at line 1374 of file Geometry.cpp.

References m_a, m_b, and m_c.

Referenced by getTangentLine(), and makeLineFromTwoPoints().


Member Function Documentation

void Line::show ( ostream &  os = cout  ) 

This method prints the line information to the specified output stream.

Parameters:
os output stream to which output is written.

Definition at line 1410 of file Geometry.cpp.

Referenced by getYGivenX().

VecPosition Line::getIntersection ( Line  line  ) 

This method returns the intersection point between the current Line and the specified line.

Parameters:
line line with which the intersection should be calculated.
Returns:
VecPosition position that is the intersection point.

Definition at line 1419 of file Geometry.cpp.

References getACoefficient(), getBCoefficient(), getCCoefficient(), getYGivenX(), m_a, m_b, and m_c.

Referenced by BasicPlayer::clearBall(), BasicPlayer::defendGoalLine(), Player::deMeer5_goalie(), WorldModel::getOuterPositionInField(), getPointOnLineClosestTo(), BasicPlayer::getShootPositionOnLine(), BasicPlayer::interceptScoringAttempt(), WorldModel::isBallHeadingToGoal(), BasicPlayer::kickBallCloseToBody(), and BasicPlayer::moveToPosAlongLine().

int Line::getCircleIntersectionPoints ( Circle  circle,
VecPosition posSolution1,
VecPosition posSolution2 
)

This method calculates the intersection points between the current line and the circle specified with as center 'posCenter' and radius 'dRadius'. The number of solutions are returned and the corresponding points are put in the third and fourth argument of the method

Parameters:
c circle with which intersection points should be found
posSolution1 first intersection (if any)
posSolution2 second intersection (if any)

Definition at line 1458 of file Geometry.cpp.

References Geometry::abcFormula(), EPSILON, Circle::getCenter(), Circle::getRadius(), VecPosition::getX(), VecPosition::getY(), m_a, m_b, m_c, and VecPosition::setVecPosition().

Referenced by BasicPlayer::interceptClose().

Line Line::getTangentLine ( VecPosition  pos  ) 

This method returns the tangent line to a VecPosition. This is the line between the specified position and the closest point on the line to this position.

Parameters:
pos VecPosition point with which tangent line is calculated.
Returns:
Line line tangent to this position

Definition at line 1508 of file Geometry.cpp.

References VecPosition::getX(), VecPosition::getY(), Line(), m_a, and m_b.

Referenced by getPointOnLineClosestTo().

VecPosition Line::getPointOnLineClosestTo ( VecPosition  pos  ) 

This method returns the closest point on a line to a given position.

Parameters:
pos point to which closest point should be determined
Returns:
VecPosition closest point on line to 'pos'.

Definition at line 1519 of file Geometry.cpp.

References getIntersection(), and getTangentLine().

Referenced by WorldModel::getClosestInSetTo(), getDistanceWithPoint(), WorldModel::getMarkingPosition(), WorldModel::getNrInSetInCone(), BasicPlayer::interceptCloseGoalie(), isInBetween(), BasicPlayer::kickTo(), BasicPlayer::moveToPosAlongLine(), and BasicPlayer::outplayOpponent().

double Line::getDistanceWithPoint ( VecPosition  pos  ) 

This method returns the distance between a specified position and the closest point on the given line.

Parameters:
pos position to which distance should be calculated
Returns:
double indicating the distance to the line.

Definition at line 1529 of file Geometry.cpp.

References VecPosition::getDistanceTo(), and getPointOnLineClosestTo().

Referenced by WorldModel::predictCommandTurnTowards().

bool Line::isInBetween ( VecPosition  pos,
VecPosition  point1,
VecPosition  point2 
)

This method determines whether the projection of a point on the current line lies between two other points ('point1' and 'point2') that lie on the same line.

Parameters:
pos point of which projection is checked.
point1 first point on line
point2 second point on line
Returns:
true when projection of 'pos' lies between 'point1' and 'point2'.

Definition at line 1542 of file Geometry.cpp.

References VecPosition::getDistanceTo(), and getPointOnLineClosestTo().

Referenced by WorldModel::getClosestInSetTo(), WorldModel::getMarkingPosition(), and WorldModel::getNrInSetInCone().

double Line::getYGivenX ( double  x  ) 

This method calculates the y coordinate given the x coordinate

Parameters:
x coordinate
Returns:
y coordinate on this line

Definition at line 1556 of file Geometry.cpp.

References m_a, m_b, m_c, and show().

Referenced by getIntersection(), and WorldModel::getMarkingPosition().

double Line::getXGivenY ( double  y  ) 

This method calculates the x coordinate given the x coordinate

Parameters:
y coordinate
Returns:
x coordinate on this line

Definition at line 1572 of file Geometry.cpp.

References m_a, m_b, and m_c.

double Line::getACoefficient (  )  const

This method returns the a coefficient from the line ay + bx + c = 0.

Returns:
a coefficient of the line.

Definition at line 1624 of file Geometry.cpp.

References m_a.

Referenced by getIntersection(), and operator<<().

double Line::getBCoefficient (  )  const

This method returns the b coefficient from the line ay + bx + c = 0.

Returns:
b coefficient of the line.

Definition at line 1631 of file Geometry.cpp.

References m_b.

Referenced by getIntersection(), and operator<<().

double Line::getCCoefficient (  )  const

This method returns the c coefficient from the line ay + bx + c = 0.

Returns:
c coefficient of the line.

Definition at line 1638 of file Geometry.cpp.

References m_c.

Referenced by getIntersection(), and operator<<().

Line Line::makeLineFromTwoPoints ( VecPosition  pos1,
VecPosition  pos2 
) [static]

This method creates a line given two points.

Parameters:
pos1 first point
pos2 second point
Returns:
line that passes through the two specified points.

Definition at line 1587 of file Geometry.cpp.

References EPSILON, VecPosition::getX(), VecPosition::getY(), and Line().

Referenced by BasicPlayer::clearBall(), BasicPlayer::defendGoalLine(), Player::deMeer5_goalie(), WorldModel::getMarkingPosition(), WorldModel::getNrInSetInCone(), BasicPlayer::getShootPositionOnLine(), WorldModel::isBallHeadingToGoal(), BasicPlayer::kickTo(), makeLineFromPositionAndAngle(), and BasicPlayer::moveToPosAlongLine().

Line Line::makeLineFromPositionAndAngle ( VecPosition  vec,
AngDeg  angle 
) [static]

This method creates a line given a position and an angle.

Parameters:
vec position through which the line passes
angle direction of the line.
Returns:
line that goes through position 'vec' with angle 'angle'.

Definition at line 1615 of file Geometry.cpp.

References makeLineFromTwoPoints(), and POLAR.

Referenced by BasicPlayer::clearBall(), BasicPlayer::defendGoalLine(), WorldModel::getOuterPositionInField(), BasicPlayer::getShootPositionOnLine(), BasicPlayer::interceptClose(), BasicPlayer::interceptCloseGoalie(), BasicPlayer::interceptScoringAttempt(), WorldModel::isBallHeadingToGoal(), BasicPlayer::kickBallCloseToBody(), BasicPlayer::moveToPosAlongLine(), BasicPlayer::outplayOpponent(), and WorldModel::predictCommandTurnTowards().


Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
Line  l 
) [friend]

This function prints the line to the specified output stream in the format y = ax + b.

Parameters:
os output stream to which output is written
l line that is written to output stream
Returns:
output sream to which output is appended.

Definition at line 1386 of file Geometry.cpp.


Field Documentation

double Line::m_a [private]

This is the a coefficient in the line ay + bx + c = 0

Definition at line 276 of file Geometry.h.

Referenced by getACoefficient(), getCircleIntersectionPoints(), getIntersection(), getTangentLine(), getXGivenY(), getYGivenX(), and Line().

double Line::m_b [private]

This is the b coefficient in the line ay + bx + c = 0

Definition at line 277 of file Geometry.h.

Referenced by getBCoefficient(), getCircleIntersectionPoints(), getIntersection(), getTangentLine(), getXGivenY(), getYGivenX(), and Line().

double Line::m_c [private]

This is the c coefficient in the line ay + bx + c = 0

Definition at line 278 of file Geometry.h.

Referenced by getCCoefficient(), getCircleIntersectionPoints(), getIntersection(), getXGivenY(), getYGivenX(), and Line().


The documentation for this class was generated from the following files:
Generated on Thu Apr 26 22:45:31 2007 for GangOfSix(GOS)-RoboCupTeamProject by  doxygen 1.5.1-p1