LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Static Public Member Functions | List of all members
rcsc::Rect2D Class Reference

2D rectangle regin class. More...

#include <rect_2d.h>

Inheritance diagram for rcsc::Rect2D:
Inheritance graph
[legend]
Collaboration diagram for rcsc::Rect2D:
Collaboration graph
[legend]

Public Member Functions

 Rect2D ()
 default constructor creates a zero area rectanble at (0,0)
 
 Rect2D (const Vector2D &top_left, const Size2D &size)
 constructor with variables More...
 
 Rect2D (const Vector2D &top_left, const Vector2D &bottom_right)
 constructor with 2 points. More...
 
const Rect2Dassign (const Vector2D &top_left, const Size2D &size)
 assign new values More...
 
const Rect2DmoveCenter (const Vector2D &point)
 move the rectangle. the center point is set to the given position. the size is unchanged. More...
 
const Rect2DmoveTopLeft (const Vector2D &point)
 move the rectangle. the top-left coner is set to the given position. the size is unchanged. More...
 
const Rect2DmoveBottomRight (const Vector2D &point)
 move the rectangle. the bottom-right coner is set to the given position. the size is unchanged. More...
 
const Rect2DmoveLeft (const double x)
 move the rectangle. the left line is set to the given position. the size is unchanged. More...
 
const Rect2DmoveMinX (const double x)
 alias of moveLeft. More...
 
const Rect2DmoveRight (const double x)
 move the rectangle. the right line is set to the given value. the size is unchanged. More...
 
const Rect2DmoveMaxX (const double x)
 alias of moveRight. More...
 
const Rect2DmoveTop (const double y)
 move the rectangle. the top line is set to the given value. the size is unchanged. More...
 
const Rect2DmoveMinY (const double y)
 alias of moveTop. More...
 
const Rect2DmoveBottom (const double y)
 move the rectangle. the top line is set to the given value. the size is unchanged. More...
 
const Rect2DmoveMaxY (const double y)
 alias of moveTop. More...
 
const Rect2DsetTopLeft (const double x, const double y)
 set the top-left corner of the rectangle. the size may be changed, but the bottom-right corner will never be changed. More...
 
const Rect2DsetTopLeft (const Vector2D &point)
 set the top-left corner of the rectangle. the size may be changed, but the bottom-right corner will never be changed. More...
 
const Rect2DsetBottomRight (const double x, const double y)
 set the bottom-right corner of the rectangle. the size may be changed, but the top-left corner will never be changed. More...
 
const Rect2DsetBottomRight (const Vector2D &point)
 set the bottom-right corner of the rectangle. the size may be changed, but the top-left corner will never be changed. More...
 
const Rect2DsetLeft (const double x)
 set the left of rectangle. the size may be changed, but the right will never be changed. More...
 
const Rect2DsetMinX (const double x)
 alias of setLeft. More...
 
const Rect2DsetRight (const double x)
 set the right of rectangle. the size may be changed, but the left will never be changed. More...
 
const Rect2DsetMaxX (const double x)
 alias of setRight. More...
 
const Rect2DsetTop (const double y)
 set the top of rectangle. the size may be changed, but the bottom will never be changed. More...
 
const Rect2DsetMinY (const double y)
 alias of setTop. More...
 
const Rect2DsetBottom (const double y)
 set the bottom of rectangle. the size may be changed, but the top will never be changed. More...
 
const Rect2DsetMaxY (const double y)
 alias of setBottom. More...
 
const Rect2DsetLength (const double length)
 set a new x-range More...
 
const Rect2DsetWidth (const double width)
 set a new y-range More...
 
const Rect2DsetSize (const double length, const double width)
 set a new size More...
 
const Rect2DsetSize (const Size2D &size)
 set a new size More...
 
bool isValid () const
 check if this rectangle is valid or not. More...
 
virtual double area () const
 get the area value of this rectangle. More...
 
virtual bool contains (const Vector2D &point) const
 check if point is within this region. More...
 
bool contains (const Vector2D &point, const double error_thr) const
 check if point is within this region with error threshold. More...
 
double left () const
 get the left x coordinate of this rectangle. More...
 
double right () const
 get the right x coordinate of this rectangle. More...
 
double top () const
 get the top y coordinate of this rectangle. More...
 
double bottom () const
 get the bottom y coordinate of this rectangle. More...
 
double minX () const
 get minimum value of x coordinate of this rectangle More...
 
double maxX () const
 get maximum value of x coordinate of this rectangle More...
 
double minY () const
 get minimum value of y coordinate of this rectangle More...
 
double maxY () const
 get maximum value of y coordinate of this rectangle More...
 
const Size2Dsize () const
 get the XY range of this rectangle More...
 
Vector2D center () const
 get center point More...
 
const Vector2DtopLeft () const
 get the top-left corner point More...
 
Vector2D topRight () const
 get the top-right corner point More...
 
Vector2D bottomLeft () const
 get the bottom-left corner point More...
 
Vector2D bottomRight () const
 get the bottom-right corner point More...
 
Line2D leftEdge () const
 get the left edge line More...
 
Line2D rightEdge () const
 get the right edge line More...
 
Line2D topEdge () const
 get the top edge line More...
 
Line2D bottomEdge () const
 get the bottom edge line More...
 
int intersection (const Line2D &line, Vector2D *sol1, Vector2D *sol2) const
 calculate intersection point with line. More...
 
int intersection (const Ray2D &ray, Vector2D *sol1, Vector2D *sol2) const
 calculate intersection point with ray. More...
 
int intersection (const Segment2D &segment, Vector2D *sol1, Vector2D *sol2) const
 calculate intersection point with line segment. More...
 
const Rect2Doperator&= (const Rect2D &other)
 convert this rectangle to the intersection rectangle with other. If no intersection between rectangles, this rectangle becomes empty. More...
 
Rect2D intersected (const Rect2D &other) const
 get the intersected rectangle of this rectangle and the other rectangle. This method is equivalent to operator '&'. If no intersection between rectangles, empty rectangle is returned. More...
 
const Rect2Doperator|= (const Rect2D &other)
 convert this rectangle to the united rectangle with other. More...
 
Rect2D united (const Rect2D &other) const
 get the united rectangle of this rectangle and the other rectangle. This method is equivalent to operator '|'. More...
 
- Public Member Functions inherited from rcsc::Region2D
virtual ~Region2D ()
 virtual destructor.
 
virtual double area () const =0
 get the area of this region More...
 
virtual bool contains (const Vector2D &point) const =0
 check if this region contains 'point'. More...
 

Static Public Member Functions

static Rect2D from_center (const Vector2D &center, const double length, const double width)
 create rectangle with center point and size. More...
 
static Rect2D from_center (const double center_x, const double center_y, const double length, const double width)
 create rectangle with center point and size. More...
 
static Rect2D from_corners (const Vector2D &top_left, const Vector2D &bottom_right)
 create rectangle with 2 corner points. just call one of constructor. More...
 
static Rect2D from_corners (const double l, const double t, const double r, const double b)
 create rectangle with 2 corner points. just call one of constructor. More...
 

Additional Inherited Members

- Protected Member Functions inherited from rcsc::Region2D
 Region2D ()
 accessible only from derived classes
 

Detailed Description

2D rectangle regin class.

The model and naming rules are depend on soccer simulator environment -34.0 | | -52.5 ---—+----— 52.5 | | 34.0

Constructor & Destructor Documentation

◆ Rect2D() [1/2]

rcsc::Rect2D::Rect2D ( const Vector2D top_left,
const Size2D size 
)
inline

constructor with variables

Parameters
top_lefttop left point
sizeXY range

◆ Rect2D() [2/2]

rcsc::Rect2D::Rect2D ( const Vector2D top_left,
const Vector2D bottom_right 
)
inline

constructor with 2 points.

Parameters
top_lefttop left vertex
bottom_rightbottom right vertex

Even if argument point has incorrect values, the assigned values are normalized automatically.

Member Function Documentation

◆ area()

virtual double rcsc::Rect2D::area ( ) const
inlinevirtual

get the area value of this rectangle.

Returns
value of the area

Implements rcsc::Region2D.

◆ assign()

const Rect2D & rcsc::Rect2D::assign ( const Vector2D top_left,
const Size2D size 
)
inline

assign new values

Parameters
top_lefttop left
sizeXY range
Returns
const referenct to itself

◆ bottom()

double rcsc::Rect2D::bottom ( ) const
inline

get the bottom y coordinate of this rectangle.

Returns
y coordinate value

◆ bottomEdge()

Line2D rcsc::Rect2D::bottomEdge ( ) const
inline

get the bottom edge line

Returns
line object

◆ bottomLeft()

Vector2D rcsc::Rect2D::bottomLeft ( ) const
inline

get the bottom-left corner point

Returns
coordiante value by vector object

◆ bottomRight()

Vector2D rcsc::Rect2D::bottomRight ( ) const
inline

get the bottom-right corner point

Returns
coordiante value by vector object

◆ center()

Vector2D rcsc::Rect2D::center ( ) const
inline

get center point

Returns
coordinate value by vector object

◆ contains() [1/2]

virtual bool rcsc::Rect2D::contains ( const Vector2D point) const
inlinevirtual

check if point is within this region.

Parameters
pointconsidered point
Returns
true or false

Implements rcsc::Region2D.

◆ contains() [2/2]

bool rcsc::Rect2D::contains ( const Vector2D point,
const double  error_thr 
) const
inline

check if point is within this region with error threshold.

Parameters
pointconsidered point
error_threrror threshold
Returns
true or false

◆ from_center() [1/2]

static Rect2D rcsc::Rect2D::from_center ( const double  center_x,
const double  center_y,
const double  length,
const double  width 
)
inlinestatic

create rectangle with center point and size.

Parameters
center_xx value of center point of new rectangle.
center_yy value of center point of new rectangle.
lengthlength(x-range) of new rectangle.
widthwidth(y-range) of new rectangle.

◆ from_center() [2/2]

static Rect2D rcsc::Rect2D::from_center ( const Vector2D center,
const double  length,
const double  width 
)
inlinestatic

create rectangle with center point and size.

Parameters
centercenter point of new rectangle.
lengthlength(x-range) of new rectangle.
widthwidth(y-range) of new rectangle.

◆ from_corners() [1/2]

static Rect2D rcsc::Rect2D::from_corners ( const double  l,
const double  t,
const double  r,
const double  b 
)
inlinestatic

create rectangle with 2 corner points. just call one of constructor.

Parameters
lleft x
ttop y
rright x
bbottom y

◆ from_corners() [2/2]

static Rect2D rcsc::Rect2D::from_corners ( const Vector2D top_left,
const Vector2D bottom_right 
)
inlinestatic

create rectangle with 2 corner points. just call one of constructor.

Parameters
top_lefttop left vertex
bottom_rightbottom right vertex

◆ intersected()

Rect2D rcsc::Rect2D::intersected ( const Rect2D other) const
inline

get the intersected rectangle of this rectangle and the other rectangle. This method is equivalent to operator '&'. If no intersection between rectangles, empty rectangle is returned.

Parameters
otherother rectangle
Returns
new rectangle instance.

◆ intersection() [1/3]

int rcsc::Rect2D::intersection ( const Line2D line,
Vector2D sol1,
Vector2D sol2 
) const

calculate intersection point with line.

Parameters
lineconsiderd line.
sol1pointer to the 1st solution variable
sol2pointer to the 2nd solution variable
Returns
number of intersection

◆ intersection() [2/3]

int rcsc::Rect2D::intersection ( const Ray2D ray,
Vector2D sol1,
Vector2D sol2 
) const

calculate intersection point with ray.

Parameters
rayconsiderd ray line.
sol1pointer to the 1st solution variable
sol2pointer to the 2nd solution variable
Returns
number of intersection

◆ intersection() [3/3]

int rcsc::Rect2D::intersection ( const Segment2D segment,
Vector2D sol1,
Vector2D sol2 
) const

calculate intersection point with line segment.

Parameters
segmentconsiderd line segment.
sol1pointer to the 1st solution variable
sol2pointer to the 2nd solution variable
Returns
number of intersection

◆ isValid()

bool rcsc::Rect2D::isValid ( ) const
inline

check if this rectangle is valid or not.

Returns
true if the area of this rectangle is not 0.

◆ left()

double rcsc::Rect2D::left ( ) const
inline

get the left x coordinate of this rectangle.

Returns
x coordinate value

◆ leftEdge()

Line2D rcsc::Rect2D::leftEdge ( ) const
inline

get the left edge line

Returns
line object

◆ maxX()

double rcsc::Rect2D::maxX ( ) const
inline

get maximum value of x coordinate of this rectangle

Returns
x coordinate value (equivalent to right())

◆ maxY()

double rcsc::Rect2D::maxY ( ) const
inline

get maximum value of y coordinate of this rectangle

Returns
y coordinate value (equivalent to bottom())

◆ minX()

double rcsc::Rect2D::minX ( ) const
inline

get minimum value of x coordinate of this rectangle

Returns
x coordinate value (equivalent to left())

◆ minY()

double rcsc::Rect2D::minY ( ) const
inline

get minimum value of y coordinate of this rectangle

Returns
y coordinate value (equivalent to top())

◆ moveBottom()

const Rect2D & rcsc::Rect2D::moveBottom ( const double  y)
inline

move the rectangle. the top line is set to the given value. the size is unchanged.

Parameters
ynew top value
Returns
const referenct to itself

◆ moveBottomRight()

const Rect2D & rcsc::Rect2D::moveBottomRight ( const Vector2D point)
inline

move the rectangle. the bottom-right coner is set to the given position. the size is unchanged.

Parameters
pointnew bottom-right conrer
Returns
const referenct to itself

◆ moveCenter()

const Rect2D & rcsc::Rect2D::moveCenter ( const Vector2D point)
inline

move the rectangle. the center point is set to the given position. the size is unchanged.

Parameters
pointnew center coordinates
Returns
const referenct to itself

◆ moveLeft()

const Rect2D & rcsc::Rect2D::moveLeft ( const double  x)
inline

move the rectangle. the left line is set to the given position. the size is unchanged.

Parameters
xnew left value
Returns
const referenct to itself

◆ moveMaxX()

const Rect2D & rcsc::Rect2D::moveMaxX ( const double  x)
inline

alias of moveRight.

Parameters
xnew right value
Returns
const referenct to itself

◆ moveMaxY()

const Rect2D & rcsc::Rect2D::moveMaxY ( const double  y)
inline

alias of moveTop.

Parameters
ynew top value
Returns
const referenct to itself

◆ moveMinX()

const Rect2D & rcsc::Rect2D::moveMinX ( const double  x)
inline

alias of moveLeft.

Parameters
xnew left value
Returns
const referenct to itself

◆ moveMinY()

const Rect2D & rcsc::Rect2D::moveMinY ( const double  y)
inline

alias of moveTop.

Parameters
ynew top value
Returns
const referenct to itself

◆ moveRight()

const Rect2D & rcsc::Rect2D::moveRight ( const double  x)
inline

move the rectangle. the right line is set to the given value. the size is unchanged.

Parameters
xnew right value
Returns
const referenct to itself

◆ moveTop()

const Rect2D & rcsc::Rect2D::moveTop ( const double  y)
inline

move the rectangle. the top line is set to the given value. the size is unchanged.

Parameters
ynew top value
Returns
const referenct to itself

◆ moveTopLeft()

const Rect2D & rcsc::Rect2D::moveTopLeft ( const Vector2D point)
inline

move the rectangle. the top-left coner is set to the given position. the size is unchanged.

Parameters
pointnew top-left corner
Returns
const referenct to itself

◆ operator&=()

const Rect2D & rcsc::Rect2D::operator&= ( const Rect2D other)

convert this rectangle to the intersection rectangle with other. If no intersection between rectangles, this rectangle becomes empty.

Parameters
otherother rectangle.
Returns
const reference to this.

◆ operator|=()

const Rect2D & rcsc::Rect2D::operator|= ( const Rect2D other)

convert this rectangle to the united rectangle with other.

Parameters
otherother rectangle.
Returns
const reference to this.

◆ right()

double rcsc::Rect2D::right ( ) const
inline

get the right x coordinate of this rectangle.

Returns
x coordinate value

◆ rightEdge()

Line2D rcsc::Rect2D::rightEdge ( ) const
inline

get the right edge line

Returns
line object

◆ setBottom()

const Rect2D & rcsc::Rect2D::setBottom ( const double  y)

set the bottom of rectangle. the size may be changed, but the top will never be changed.

Parameters
ynew bottom value
Returns
const referenct to itself

◆ setBottomRight() [1/2]

const Rect2D & rcsc::Rect2D::setBottomRight ( const double  x,
const double  y 
)

set the bottom-right corner of the rectangle. the size may be changed, but the top-left corner will never be changed.

Parameters
xnew x coordinate
ynew y coordinate
Returns
const referenct to itself

◆ setBottomRight() [2/2]

const Rect2D & rcsc::Rect2D::setBottomRight ( const Vector2D point)
inline

set the bottom-right corner of the rectangle. the size may be changed, but the top-left corner will never be changed.

Parameters
pointnew coordinate
Returns
const referenct to itself

◆ setLeft()

const Rect2D & rcsc::Rect2D::setLeft ( const double  x)

set the left of rectangle. the size may be changed, but the right will never be changed.

Parameters
xnew left value
Returns
const referenct to itself

◆ setLength()

const Rect2D & rcsc::Rect2D::setLength ( const double  length)
inline

set a new x-range

Parameters
lengthnew range
Returns
const referenct to itself

◆ setMaxX()

const Rect2D & rcsc::Rect2D::setMaxX ( const double  x)
inline

alias of setRight.

Parameters
xnew right value
Returns
const referenct to itself

◆ setMaxY()

const Rect2D & rcsc::Rect2D::setMaxY ( const double  y)
inline

alias of setBottom.

Parameters
ynew top value
Returns
const referenct to itself

◆ setMinX()

const Rect2D & rcsc::Rect2D::setMinX ( const double  x)
inline

alias of setLeft.

Parameters
xnew left value
Returns
const referenct to itself

◆ setMinY()

const Rect2D & rcsc::Rect2D::setMinY ( const double  y)
inline

alias of setTop.

Parameters
ynew top value
Returns
const referenct to itself

◆ setRight()

const Rect2D & rcsc::Rect2D::setRight ( const double  x)

set the right of rectangle. the size may be changed, but the left will never be changed.

Parameters
xnew right value
Returns
const referenct to itself

◆ setSize() [1/2]

const Rect2D & rcsc::Rect2D::setSize ( const double  length,
const double  width 
)
inline

set a new size

Parameters
lengthnew range
widthnew range
Returns
const referenct to itself

◆ setSize() [2/2]

const Rect2D & rcsc::Rect2D::setSize ( const Size2D size)
inline

set a new size

Parameters
sizenew range
Returns
const referenct to itself

◆ setTop()

const Rect2D & rcsc::Rect2D::setTop ( const double  y)

set the top of rectangle. the size may be changed, but the bottom will never be changed.

Parameters
ynew top value
Returns
const referenct to itself

◆ setTopLeft() [1/2]

const Rect2D & rcsc::Rect2D::setTopLeft ( const double  x,
const double  y 
)

set the top-left corner of the rectangle. the size may be changed, but the bottom-right corner will never be changed.

Parameters
xnew x coordinate
ynew y coordinate
Returns
const referenct to itself

◆ setTopLeft() [2/2]

const Rect2D & rcsc::Rect2D::setTopLeft ( const Vector2D point)
inline

set the top-left corner of the rectangle. the size may be changed, but the bottom-right corner will never be changed.

Parameters
pointnew coordinate
Returns
const referenct to itself

◆ setWidth()

const Rect2D & rcsc::Rect2D::setWidth ( const double  width)
inline

set a new y-range

Parameters
widthnew range
Returns
const referenct to itself

◆ size()

const Size2D & rcsc::Rect2D::size ( ) const
inline

get the XY range of this rectangle

Returns
size object

◆ top()

double rcsc::Rect2D::top ( ) const
inline

get the top y coordinate of this rectangle.

Returns
y coordinate value

◆ topEdge()

Line2D rcsc::Rect2D::topEdge ( ) const
inline

get the top edge line

Returns
line object

◆ topLeft()

const Vector2D & rcsc::Rect2D::topLeft ( ) const
inline

get the top-left corner point

Returns
coordiante value by vector object

◆ topRight()

Vector2D rcsc::Rect2D::topRight ( ) const
inline

get the top-right corner point

Returns
coordiante value by vector object

◆ united()

Rect2D rcsc::Rect2D::united ( const Rect2D other) const
inline

get the united rectangle of this rectangle and the other rectangle. This method is equivalent to operator '|'.

Parameters
otherother rectangle
Returns
new rectangle instance.

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