AURobotServers
4
|
#include <u2dline.h>
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 |
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.
U2Dlined::U2Dlined | ( | const double | A, |
const double | B, | ||
const double | C | ||
) | [inline] |
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
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] |
Returns distance from point to line. To the left in vector p1->p2 direction (if set from points or point-vector), the distance will be positive.
Referenced by UAvoidPath2::avoidToTheLeft(), UPolygon::cut(), UPolygon::cutPoints(), UAvoidPath2::expandPolyToSegment(), UAvoidCellGraph::findCell(), UAvoidCellGraph::findCellPointPath(), UPose2pose::get2line(), UPose2pose::get2lineStartLeft(), UPolygon::getDistance(), UManSeq::getDistanceFromEndPoseLine(), U2Dseg::getDistanceSigned(), ULineSegment::getDistanceXYSigned(), UPolygon::getMostDistantVertexXY(), UPolygon::getMostDistantXY(), UAvoidObst::getTangentVertexFrom(), ULine::getXYsignedDistance(), UPolygon::isInsideConvex(), UResRuleState::methodCallV(), UAvoidPath2::splitObstGroup(), test2Dseg(), UAvoidPoint::tPointVisible(), UAvoidPath2::turnCentreCrossing(), and variance().
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] |
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.
line2 | is the other line |
x,y | is the crossing point, unchanged if not crossing. |
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
.
where is point on line expressed by parameter t.
. Insert into first equation.
.
find gives
. 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.
x,y | is the input x,y position |
lx,ly | is the found position on the line. |
Referenced by UResPoseHist::getPoseFitAtDistance(), UResSmrCtl::getSMRCLDrive2cmd(), and UResLocater::makeRowPolygon().
void U2Dlined::getPV | ( | double * | Px, |
double * | Py, | ||
double * | Vx, | ||
double * | Vy | ||
) |
double U2Dlined::heading | ( | ) | [inline] |
void U2Dlined::print | ( | const char * | prestring | ) |
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 |
||
) |
int U2Dlined::set2P | ( | const double | x1, |
const double | y1, | ||
const double | x2, | ||
const double | y2 | ||
) | [inline] |
Set from two points. returns -1 if too close.
Reimplemented in U2Dseg.
References setPV().
Referenced by UPolygon::cut(), UPolygon::cutPoints(), UAvoidCellGraph::findCell(), UPolygon::getDistance(), ULineSegment::getDistanceXYSigned(), UManArc::getFoodprintPolygon(), UManLine::getMinDistanceXYSigned(), UAvoidObst::getTangentVertexFrom(), and U2Dlined().
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
a | is the angle to the closest point on the line - from origo. |
r | is the distance to the closest point (from origo) to the line. |
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.
Px | is X-position (in meter) |
Py | is Y position (in meter) |
h | is heading of line in radians. |
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.
Px | is X-position (in meter) |
Py | is Y position (in meter) |
Vx | is X-component of heading vector (in meter) |
Vy | is 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 | ||
) |
bool U2Dlined::setYline | ( | double | sX, |
double | sY, | ||
double | sY2, | ||
double | sXY, | ||
int | count | ||
) |
virtual void U2Dlined::shiftLeft | ( | double | dist | ) | [inline, virtual] |
virtual void U2Dlined::shiftRight | ( | double | dist | ) | [inline, virtual] |
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.
double U2Dlined::lA [protected] |
Parameters in line equation Ax + By + C = 0
Referenced by A(), U2Dseg::clear(), distanceSigned(), fit(), fitV(), getARLine(), U2Dseg::getCircleCrossings(), U2Dseg::getHeading(), getOnLine(), U2Dseg::getPositionOnLine(), getPV(), heading(), print(), U2Dseg::print(), set(), setAR(), setXline(), setYline(), U2Dseg::shiftLeft(), U2Dseg::shiftRight(), U2Dlined(), and vy().
double U2Dlined::lB [protected] |
Referenced by B(), U2Dseg::clear(), distanceSigned(), fit(), fitV(), getARLine(), U2Dseg::getCircleCrossings(), U2Dseg::getHeading(), getOnLine(), U2Dseg::getPositionOnLine(), getPV(), heading(), print(), U2Dseg::print(), set(), setAR(), setXline(), setYline(), U2Dseg::shiftLeft(), U2Dseg::shiftRight(), U2Dlined(), and vx().
double U2Dlined::lC [protected] |
Referenced by C(), U2Dseg::clear(), distanceSigned(), fit(), fitV(), getARLine(), getOnLine(), getPV(), print(), U2Dseg::print(), set(), setAR(), setXline(), setYline(), shiftLeft(), shiftRight(), and U2Dlined().