AURobotServers  4
Public Member Functions | Protected Attributes
U2Dlined Class Reference

#include <u2dline.h>

List of all members.

Public Member Functions

double A ()
double B ()
double C ()
double distanceSigned (const double x, const double y)
bool fit (double fx[], double fy[], int count, double *V=NULL)
bool fitV (double fx[], double fy[], int count, double *V)
void getARLine (double *a, double *r)
bool getCrossing (U2Dlined L2, double *x, double *y)
void getOnLine (const double x, const double y, double *lx, double *ly)
void getPV (double *Px, double *Py, double *Vx, double *Vy)
double heading ()
void print (const char *prestring)
int set (const double A, const double B, const double C)
int set (double fx[], double fy[], int count, double *V=NULL)
int set2P (const double x1, const double y1, const double x2, const double y2)
void setAR (const double a, const double r)
int setPH (const double Px, const double Py, const double h)
int setPV (const double Px, const double Py, const double Vx, const double Vy)
bool setXline (double sX, double sY, double sX2, double sXY, int count)
bool setYline (double sX, double sY, double sY2, double sXY, int count)
virtual void shiftLeft (double dist)
virtual void shiftRight (double dist)
 U2Dlined ()
 U2Dlined (const double A, const double B, const double C)
 U2Dlined (const double a, const double r)
 U2Dlined (const double x1, const double y1, const double x2, const double y2)
double variance (double fx[], double fy[], int count, double *E=NULL)
double vx ()
double vy ()
virtual ~U2Dlined ()

Protected Attributes

double lA
double lB
double lC

Detailed Description

This is a 2D line with parameters in double precition based on line equation Ax + By + C = 0.
sqr(A) + sqr(B) is always 1.0. and should be kept that way to simplify some calculations.


Constructor & Destructor Documentation

Constructor (A=1.0, B=0.0, C=0.0 line

References lA, lB, and lC.

U2Dlined::U2Dlined ( const double  A,
const double  B,
const double  C 
) [inline]

Construct from A, B, C)

References A(), B(), and C().

U2Dlined::U2Dlined ( const double  a,
const double  r 
) [inline]

Construct from A, B, C)

References setAR().

U2Dlined::U2Dlined ( const double  x1,
const double  y1,
const double  x2,
const double  y2 
) [inline]

Construct from 2 points

References set2P().

virtual U2Dlined::~U2Dlined ( ) [inline, virtual]

Destructor


Member Function Documentation

double U2Dlined::A ( ) [inline]

Get A parameter in Ax + By + C = 0

References lA.

Referenced by getCrossing(), UResAuEf::initializeWalls(), set(), U2Dlined(), and UResAuEf::updateWalls().

double U2Dlined::B ( ) [inline]

Get B parameter in Ax + By + C = 0

References lB.

Referenced by getCrossing(), UResAuEf::initializeWalls(), set(), U2Dlined(), and UResAuEf::updateWalls().

double U2Dlined::C ( ) [inline]

Get C parameter in Ax + By + C = 0

References lC.

Referenced by getCrossing(), set(), setPH(), setPV(), U2Dlined(), and UResAuEf::updateWalls().

double U2Dlined::distanceSigned ( const double  x,
const double  y 
) [inline]
bool U2Dlined::fit ( double  fx[],
double  fy[],
int  count,
double *  V = NULL 
)

Set as best fit line through a series of points. if V != NULL then the variance is returned here

References absd(), lA, lB, lC, sqr(), and variance().

Referenced by UResPoseHist::getPoseFitAtDistance(), and test2DlineFit().

bool U2Dlined::fitV ( double  fx[],
double  fy[],
int  count,
double *  V 
)

References absd(), lA, lB, lC, sqr(), and variance().

Referenced by test2DlineFit().

void U2Dlined::getARLine ( double *  a,
double *  r 
) [inline]

Get line described as alpha,r, where r is distance to line from origo and alpha is the angle to the thpoint on the line closest to the origo.

Parameters:
ais where the alpha angle is returned.
ris where the distance to the line is returned

References lA, lB, and lC.

bool U2Dlined::getCrossing ( U2Dlined  L2,
double *  x,
double *  y 
)

Find crossing between this line and line L2. Returns the result in x and y if the lines are not parallel.

Parameters:
line2is the other line
x,yis the crossing point, unchanged if not crossing.
Returns:
false if lines are parallel.

References A(), B(), and C().

Referenced by UPolygon::cut(), UPolygon::cutPoints(), UAvoidCellGraph::findCellPointPath(), UManArc::getFoodprintPolygon(), UManLine::getMinDistanceXYSigned(), ULine::getXYCrossing(), U2Dseg::isCrossing(), and UResAuEf::updateWalls().

void U2Dlined::getOnLine ( const double  x,
const double  y,
double *  lx,
double *  ly 
)

Get nearest point on line to this point. Found by minimizing distance
$ d = \sqrt{(x_l - x)^2+(y_l - y)^2} $.
where $(x_l, y_l)$ is point on line expressed by parameter t.
$ [x_l,y_l] = [P_x,P_y] + [V_x,V_y] * t $. Insert into first equation.
$ d^2 = (P_x + V_x * t - x)^2 + (P_y + V_y * t - y)^2 $.
find $ \frac{d d^2}{dt} = 0$ gives
$ t = (-P_x * V_x + V_x * x - P_y * V_y + V_y * y)/((V_x^2 + V_y^2) $. Denominator is equal to 1.0 and can be ignored. Setting t into point-vector line expression gives nearest (lx,ly) point on line. Px, Py, Vx, Vy can then be replaced by A,B,C to simplify expression.

Parameters:
x,yis the input x,y position
lx,lyis the found position on the line.

References lA, lB, and lC.

Referenced by UResPoseHist::getPoseFitAtDistance(), UResSmrCtl::getSMRCLDrive2cmd(), and UResLocater::makeRowPolygon().

void U2Dlined::getPV ( double *  Px,
double *  Py,
double *  Vx,
double *  Vy 
)

Get line as in position - vector format on the form [x,y] = [Px,Py] + [Vx,Vy]*t Either Px or Py will be zero.

References absf(), lA, lB, and lC.

double U2Dlined::heading ( ) [inline]

Get line heading in radians

Reimplemented in U2Dseg.

References lA, and lB.

void U2Dlined::print ( const char *  prestring)

Print A, B, C to console

References lA, lB, and lC.

Referenced by test2DlineFit().

int U2Dlined::set ( const double  A,
const double  B,
const double  C 
) [inline]

Set line from known A, B, C values in the line equation Ax + By + C = 0

References A(), B(), C(), lA, lB, and lC.

Referenced by UResAuEf::findFeatures(), UResAuEf::initializeWalls(), and UResAuEf::updateWalls().

int U2Dlined::set ( double  fx[],
double  fy[],
int  count,
double *  V = NULL 
)

Set as best fit line through a series of points. if V != NULL then the variance is returned here

References absd(), lA, lB, lC, sqr(), and variance().

int U2Dlined::set2P ( const double  x1,
const double  y1,
const double  x2,
const double  y2 
) [inline]
void U2Dlined::setAR ( const double  a,
const double  r 
) [inline]

Sets the line from an alpha (a) and r notation. like A = cos(a), B = sin(a), C = -r

Parameters:
ais the angle to the closest point on the line - from origo.
ris the distance to the closest point (from origo) to the line.

References lA, lB, and lC.

Referenced by U2Dlined().

int U2Dlined::setPH ( const double  Px,
const double  Py,
const double  h 
)

Set line from point-heading format. the resulting line is normalized, so that the A,B vector is a unit vector.

Parameters:
Pxis X-position (in meter)
Pyis Y position (in meter)
his heading of line in radians.
Returns:
0.

References C().

Referenced by UManSeq::getDistanceFromEndPoseLine(), UResSmrCtl::getSMRCLDrive2cmd(), UResRuleState::methodCallV(), U2Dseg::setFromPoints(), U2Dseg::setFromPose(), and UAvoidPath2::splitObstGroup().

int U2Dlined::setPV ( const double  Px,
const double  Py,
const double  Vx,
const double  Vy 
)

Set line from point-vector format. the resulting line is normalized, so that the A,B vector is a unit vector.

Parameters:
Pxis X-position (in meter)
Pyis Y position (in meter)
Vxis X-component of heading vector (in meter)
Vyis Y component of heading vector (in meter) returns -1 if zero vector.

References C().

Referenced by UPolygon::getMostDistantVertexXY(), UPolygon::getMostDistantXY(), ULine::getXYCrossing(), ULine::getXYsignedDistance(), UResRuleState::methodCallV(), and set2P().

bool U2Dlined::setXline ( double  sX,
double  sY,
double  sX2,
double  sXY,
int  count 
)

Set line parameters, assuming that the line is more or less parallel with the x-axis

References absd(), lA, lB, lC, and sqr().

bool U2Dlined::setYline ( double  sX,
double  sY,
double  sY2,
double  sXY,
int  count 
)

Set line parameters, assuming that the line is more or less parallel with the y-axis

References absd(), lA, lB, lC, and sqr().

virtual void U2Dlined::shiftLeft ( double  dist) [inline, virtual]

Shift the line this distance to the Left This moves the C parameter and the start position.

Parameters:
distis the distance shifted.

Reimplemented in U2Dseg.

References lC.

virtual void U2Dlined::shiftRight ( double  dist) [inline, virtual]

Shift the line this distance to the Right This moves the C parameter and the start position.

Parameters:
distis the distance shifted.

Reimplemented in U2Dseg.

References lC.

double U2Dlined::variance ( double  fx[],
double  fy[],
int  count,
double *  E = NULL 
)

Get mean and variance for the distance from these points to the line if E == NULL then mean is not returned. if no points are given, then -1.0 is returned

References distanceSigned(), and sqr().

Referenced by fit(), fitV(), set(), and test2DlineFit().

double U2Dlined::vx ( ) [inline]

Get line vextor X component

References lB.

double U2Dlined::vy ( ) [inline]

Get line vextor Y component

References lA.


Member Data Documentation

double U2Dlined::lA [protected]
double U2Dlined::lB [protected]
double U2Dlined::lC [protected]

The documentation for this class was generated from the following files: