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 | ( | ) |
Constructor (A=1.0, B=0.0, C=0.0 line
References U2Dline::lA, U2Dline::lB, and U2Dline::lC.
|
inline |
Construct from A, B, C)
References U2Dline::A(), U2Dline::B(), and U2Dline::C().
|
inline |
Construct from A, B, C)
|
inline |
Construct from 2 points
References U2Dline::set2P().
|
inlinevirtual |
Destructor
|
inline |
Get A parameter in Ax + By + C = 0
References U2Dline::lA.
Referenced by getCrossing(), UResAuEf::initializeWalls(), and UResAuEf::updateWalls().
|
inline |
Get B parameter in Ax + By + C = 0
References U2Dline::lB.
Referenced by getCrossing(), UResAuEf::initializeWalls(), and UResAuEf::updateWalls().
|
inline |
Get C parameter in Ax + By + C = 0
References U2Dline::lC.
Referenced by getCrossing(), and UResAuEf::updateWalls().
|
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.
References U2Dline::getCrossing(), U2Dline::getOnLine(), U2Dline::lA, U2Dline::lB, U2Dline::lC, and U2Dline::print().
Referenced by UAvoidPath2::avoidToTheLeft(), UPolygon::cut(), UPolygon::cutPoints(), UAvoidPath2::expandPolyToSegment(), UAvoidCellGraph::findCell(), UAvoidCellGraph::findCellPointPath(), UPose2pose::get2line(), UPose2pose::get2lineStartLeft(), UPolygon::getDistance(), UManSeq::getDistanceFromEndPoseLine(), ULineSegment::getDistanceXYSigned(), UPolygon::getMostDistantVertexXY(), UPolygon::getMostDistantXY(), UAvoidObst::getTangentVertexFrom(), ULine::getXYsignedDistance(), UPolygon::isInsideConvex(), UResRuleState::methodCallV(), UAvoidPath2::splitObstGroup(), test2Dseg(), UAvoidPoint::tPointVisible(), and UAvoidPath2::turnCentreCrossing().
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 a, absd(), U2Dline::lA, U2Dline::lB, U2Dline::lC, sqr(), and U2Dline::variance().
Referenced by UResPoseHist::getPoseFitAtDistance(), and test2DlineFit().
bool U2Dlined::fitV | ( | double | fx[], |
double | fy[], | ||
int | count, | ||
double * | V | ||
) |
References a, absd(), U2Dline::lA, U2Dline::lB, U2Dline::lC, sqr(), and U2Dline::variance().
Referenced by test2DlineFit().
|
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.
a | is where the alpha angle is returned. |
r | is where the distance to the line is returned |
References U2Dline::lA, U2Dline::lB, and U2Dline::lC.
Referenced by UFuncLoca2::correlateLines().
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. |
References U2Dline::A(), A(), U2Dline::B(), B(), U2Dline::C(), and C().
Referenced by UPolygon::cut(), UPolygon::cutPoints(), UAvoidCellGraph::findCellPointPath(), UManArc::getFoodprintPolygon(), UManLine::getMinDistanceXYSigned(), ULine::getXYCrossing(), 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. |
References U2Dline::lA, U2Dline::lB, and U2Dline::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(), U2Dline::lA, U2Dline::lB, and U2Dline::lC.
|
inline |
Get line heading in radians
References U2Dline::getPV(), U2Dline::lA, U2Dline::lB, and U2Dline::setPV().
Referenced by U2Dseg::heading().
void U2Dlined::print | ( | const char * | prestring | ) |
Print A, B, C to console
References U2Dline::lA, U2Dline::lB, and U2Dline::lC.
Referenced by test2DlineFit().
|
inline |
Set line from known A, B, C values in the line equation Ax + By + C = 0
References U2Dline::A(), U2Dline::B(), U2Dline::C(), U2Dline::fit(), U2Dline::lA, U2Dline::lB, U2Dline::lC, U2Dline::setXline(), U2Dline::setYline(), and U2Dline::variance().
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 a, absd(), U2Dline::lA, U2Dline::lB, U2Dline::lC, sqr(), and U2Dline::variance().
|
inline |
Set from two points. returns -1 if too close.
References U2Dline::setPV().
Referenced by UPolygon::cut(), UPolygon::cutPoints(), UAvoidCellGraph::findCell(), UPolygon::getDistance(), ULineSegment::getDistanceXYSigned(), UManArc::getFoodprintPolygon(), UManLine::getMinDistanceXYSigned(), UAvoidObst::getTangentVertexFrom(), and UFuncCropRow::handleCommand().
|
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. |
References U2Dline::lA, U2Dline::lB, and U2Dline::lC.
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 U2Dline::C().
Referenced by UManSeq::getDistanceFromEndPoseLine(), UResSmrCtl::getSMRCLDrive2cmd(), UResRuleState::methodCallV(), 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 U2Dline::C().
Referenced by UPolygon::getMostDistantVertexXY(), UPolygon::getMostDistantXY(), ULine::getXYCrossing(), ULine::getXYsignedDistance(), and UResRuleState::methodCallV().
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 a, absd(), U2Dline::lA, U2Dline::lB, U2Dline::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 a, absd(), U2Dline::lA, U2Dline::lB, U2Dline::lC, and sqr().
|
inlinevirtual |
Shift the line this distance to the Left This moves the C parameter and the start position.
dist | is the distance shifted. |
Reimplemented in U2Dseg.
References dist, and U2Dline::lC.
Referenced by U2Dseg::shiftLeft().
|
inlinevirtual |
Shift the line this distance to the Right This moves the C parameter and the start position.
dist | is the distance shifted. |
Reimplemented in U2Dseg.
References dist, and U2Dline::lC.
Referenced by U2Dseg::shiftRight().
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 U2Dline::distanceSigned(), and sqr().
Referenced by test2DlineFit().
|
inline |
Get line vextor X component
References U2Dline::lB.
|
inline |
Get line vextor Y component
References U2Dline::lA.
|
protected |
Parameters in line equation Ax + By + C = 0
|
protected |
|
protected |