AURobotServers  4
Public Member Functions | Public Attributes | List of all members
U2Dseg Class Reference

#include <u2dline.h>

Inheritance diagram for U2Dseg:
Inheritance graph

Public Member Functions

virtual void clear ()
 
const char * codeXml (const char *name, char *buff, const int buffCnt, const char *extraAtt)
 
int getCircleCrossings (double cx, double cy, double r, double *t1, double *t2)
 
virtual const char * getDataType ()
 
double getDistanceSigned (double px, double py, int *where)
 
U2Dpos getFirstEnd ()
 
double getHeading ()
 
U2Dpos getOtherEnd ()
 
U2Dpos getPositionOnLine (const double t)
 
double getPositionOnLine (U2Dpos *point)
 
double getPositionOnLine (U2Dpos point)
 
double getPositionOnLine (double px, double py)
 
double heading ()
 
bool isCrossing (U2Dseg *other, U2Dpos *crossing)
 
const char * print (const char *prestring, char *buff, const int buffCnt)
 
int set2P (const double x1, const double y1, const double x2, const double y2)
 
void setFromPoints (const UPosition *pos1, const UPosition *pos2)
 
void setFromPoints (UPosition pos1, UPosition pos2)
 
void setFromPoints (U2Dpos pos1, U2Dpos pos2)
 
void setFromPoints (double x1, double y1, double x2, double y2)
 
void setFromPose (double x1, double y1, double h1, double len=1.0)
 
virtual void shiftLeft (double dist)
 
virtual void shiftRight (double dist)
 
 U2Dseg ()
 
virtual ~U2Dseg ()
 
- Public Member Functions inherited from U2Dlined
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)
 
 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 ()
 
- Public Member Functions inherited from U2Dpos
UMatrix4 asCol2 ()
 
UMatrix4 asCol3 ()
 
UMatrix4 asRow2 ()
 
UMatrix4 asRow3 ()
 
void clear ()
 
double dist ()
 
double dist (UPosition b)
 
double dist (U2Dpos b)
 
double heading ()
 
double length ()
 
U2Dpos operator= (UPosition pos)
 
U2Dpos operator= (U2Dseg seg)
 
void set (double ix, double iy)
 
 U2Dpos (double ix, double iy)
 
 U2Dpos ()
 
- Public Member Functions inherited from UDataBase
bool isA (const char *typeString)
 
virtual bool isAlsoA (const char *typeString)
 
virtual void snprint (const char *preString, char *buff, const int buffCnt)
 
 UDataBase ()
 
virtual ~UDataBase ()
 

Public Attributes

double length
 
- Public Attributes inherited from U2Dpos
double x
 
double y
 

Additional Inherited Members

- Protected Attributes inherited from U2Dlined
double lA
 
double lB
 
double lC
 

Detailed Description

This is a 2D line with parameters in double precition

Constructor & Destructor Documentation

U2Dseg::U2Dseg ( )
inline

Constructor

virtual U2Dseg::~U2Dseg ( )
inlinevirtual

destructor

Member Function Documentation

void U2Dseg::clear ( void  )
virtual

Clear

References U2Dline::lA, U2Dline::lB, and U2Dline::lC.

Referenced by UResLocater::makeRowPolygon().

const char * U2Dseg::codeXml ( const char *  name,
char *  buff,
const int  buffCnt,
const char *  extraAtt 
)

Code this line as an XML tag into this string buffer. like <line name="" x="" y="" th="" length="" [extraAtt]/>

Parameters
nameis an optional value to a name attribute .
buffis the buffer to write into.
buffCntis the length of the buffer.
extraAttis an optional string with extra attributes to put into the tag.
Returns
a pointer to the buffer.

References U2Dline::heading().

Referenced by UResLobst::codeLines().

int U2Dseg::getCircleCrossings ( double  cx,
double  cy,
double  r,
double *  t1,
double *  t2 
)

Get crossings with a circle

Parameters
cx,cyis the center of the circle
ris the circle radius
t1,t2is the distances from the line origin to the crossings, if no crossings, then these values are unchanged.
Returns
number of crossings, and can be either 0 or 2

References U2Dline::lA, U2Dline::lB, and sqr().

Referenced by UAvoidPath2::createMidPathPoints(), and test2Dseg().

virtual const char* U2Dseg::getDataType ( )
inlinevirtual

Get (end) type string for this structure

Reimplemented from UDataBase.

double U2Dseg::getDistanceSigned ( double  px,
double  py,
int *  where 
)

Get distance from a 3D point to a line segemnt, i.e. distance to the closest end or if closer to a point on the line segment, then this distance. the distance is squared. The optional second parameter returns the closest point (if != NULL) where = 0 if on line segment, 1 if closest to 'pos', and 2 if closest to 'other end'

References dist, U2Dline::distanceSigned(), signofd(), U2Dpos::x, and U2Dpos::y.

Referenced by UAvoidPath2::getClosestObst2(), UResMapObst::getNearObstacles(), UPolygon::isInsideConvex(), UResLobst::makeObst(), and UResLocater::match_points().

U2Dpos U2Dseg::getFirstEnd ( )
inline
double U2Dseg::getHeading ( )
inline
U2Dpos U2Dseg::getOtherEnd ( )
inline
U2Dpos U2Dseg::getPositionOnLine ( const double  t)
double U2Dseg::getPositionOnLine ( U2Dpos point)

Get position parameter on the line that is closest to this point

Parameters
pointthe point anywhere in space.
Returns
a parameter on the line as a parameter. this is the distance from the closest point oin the line to the line start, signed in the direction of the segment.

References U2Dline::lA, U2Dline::lB, U2Dpos::x, and U2Dpos::y.

double U2Dseg::getPositionOnLine ( U2Dpos  point)

Get position parameter on the line that is closest to this point

Parameters
pointthe point anywhere in space.
Returns
a parameter on the line as a parameter. this is the distance from the closest point oin the line to the line start, signed in the direction of the segment.

References U2Dline::lA, U2Dline::lB, U2Dpos::x, and U2Dpos::y.

double U2Dseg::getPositionOnLine ( double  px,
double  py 
)

Get position parameter on the line that is closest to this point

Parameters
px,pythe point anywhere in space.
Returns
a parameter on the line as a parameter. this is the distance from the closest point oin the line to the line start, signed in the direction of the segment.

References U2Dline::lA, and U2Dline::lB.

double U2Dseg::heading ( )
inline

get heading of the line segment

References U2Dlined::heading().

bool U2Dseg::isCrossing ( U2Dseg other,
U2Dpos crossing 
)

Is this line segment crossing the other segment, true if crossing (within ends), and The crossing is returned in 'crossing' If no crossing is found, 'crossing' may be changed.

References U2Dline::getCrossing(), getOtherEnd(), U2Dpos::x, and U2Dpos::y.

const char * U2Dseg::print ( const char *  prestring,
char *  buff,
const int  buffCnt 
)

Same as abowe

References U2Dline::lA, U2Dline::lB, and U2Dline::lC.

Referenced by test2Dseg().

int U2Dseg::set2P ( const double  x1,
const double  y1,
const double  x2,
const double  y2 
)
inline

Set from two points. returns -1 if too close.

void U2Dseg::setFromPoints ( const UPosition pos1,
const UPosition pos2 
)
inline
void U2Dseg::setFromPoints ( UPosition  pos1,
UPosition  pos2 
)
inline

Set line from two points. Reference position is set from pos1, and other end is set to pos2 so that "pos1 + vec * length" ends at pos2.

References UPosition::x, and UPosition::y.

void U2Dseg::setFromPoints ( U2Dpos  pos1,
U2Dpos  pos2 
)
inline

Set line from two points. Reference position is set from pos1, and other end is set to pos2 so that "pos1 + vec * length" ends at pos2.

References U2Dline::print(), U2Dpos::x, and U2Dpos::y.

void U2Dseg::setFromPoints ( double  x1,
double  y1,
double  x2,
double  y2 
)

Set line segment from points. a line segment is a start point, a direction vector and a length.

Parameters
x1,y1,z1defines the first (start) point
x2,y2,z2defines the end point
void U2Dseg::setFromPose ( double  x1,
double  y1,
double  h1,
double  len = 1.0 
)

Set 2D line segment from a pose (x1, y1, h1) with an optional length.

Parameters
x,y,his the pose
lenis the optiomal length (default is 1).

Referenced by UAvoidPath2::createMidPathPoints(), UAvoidCellGraph::findCellPointPath(), UPose2pose::get2line(), UPose2pose::get2lineStartLeft(), and test2Dseg().

void U2Dseg::shiftLeft ( double  dist)
virtual

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

Parameters
distis the distance shifted.

Reimplemented from U2Dlined.

References U2Dline::lA, U2Dline::lB, and U2Dlined::shiftLeft().

void U2Dseg::shiftRight ( double  dist)
virtual

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

Parameters
distis the distance shifted.

Reimplemented from U2Dlined.

References U2Dline::lA, U2Dline::lB, and U2Dlined::shiftRight().

Member Data Documentation

double U2Dseg::length

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