Thunderbots Project
Loading...
Searching...
No Matches
Rectangle Class Reference

#include <rectangle.h>

Inheritance diagram for Rectangle:
Collaboration diagram for Rectangle:

Public Member Functions

 Rectangle (const Point &point1, const Point &point2)
 
double xLength () const
 
double yLength () const
 
Point centre () const
 
const PointposXPosYCorner () const
 
const PointnegXPosYCorner () const
 
const PointnegXNegYCorner () const
 
const PointposXNegYCorner () const
 
double xMax () const
 
double xMin () const
 
double yMax () const
 
double yMin () const
 
Vector diagonal () const
 
double halfPerimeter () const
 
Rectangle expand (double expansion_amount) const
 
bool operator== (const Rectangle &p) const
 
- Public Member Functions inherited from ConvexPolygon
double area () const override
 
 ConvexPolygon (const std::vector< Point > &points)
 
 ConvexPolygon (const std::initializer_list< Point > &points)
 
- Public Member Functions inherited from Polygon
 Polygon (const std::vector< Point > &points)
 
 Polygon (const std::initializer_list< Point > &points)
 
Point centroid () const
 
Polygon expand (double expansion_amount) const
 
double perimeter () const
 
const std::vector< Segment > & getSegments () const
 
const std::vector< Point > & getPoints () const
 

Additional Inherited Members

- Static Public Member Functions inherited from Polygon
static Polygon fromSegment (const Segment &segment, double length_radius, double width_radius)
 
static Polygon fromSegment (const Segment &segment, double radius)
 
- Protected Member Functions inherited from Polygon
void initSegments ()
 
- Protected Attributes inherited from Polygon
std::vector< Pointpoints_
 
std::vector< Segmentsegments_
 

Detailed Description

A rectangle is a ConvexPolygon of four Points with the invariant that two sides are parallel to the x axis and two sides are parallel to the y axis

Constructor & Destructor Documentation

◆ Rectangle()

Rectangle ( const Point point1,
const Point point2 
)
explicit

Creates a new Rectangle from two corners.

-----—p1/2 p1/2-----— | | | | p1/2------—* or *-----—p1/2

Parameters
point1One of the rectangle's corners
point2The corner diagonally-opposite to point1

Member Function Documentation

◆ centre()

Point centre ( ) const

Returns the centre of the rectangle

Returns
The centre of the rectangle

◆ diagonal()

Vector diagonal ( ) const

Returns a vector from negXNegY point of the rectangle to the posXPosY point

Returns
The vector representing the diagonal of the rectangle

◆ expand()

Rectangle expand ( double  expansion_amount) const

Returns the Rectangle expanded in all directions by the expansion_amount

Parameters
expansion_amounta non-negative expansion amount
Exceptions
std::invalid_argumentif expansion_amount is negative
Returns
a Rectangle expanded in all directions by the expansion amount

◆ halfPerimeter()

double halfPerimeter ( ) const

The half perimeter of the rectangle

Returns
the half perimeter of the rectangle

◆ negXNegYCorner()

const Point & negXNegYCorner ( ) const

Returns the <-x,-y> corner of the rectangle

Returns
The <-x,-y> corner of the rectangle

◆ negXPosYCorner()

const Point & negXPosYCorner ( ) const

Returns the <-x,+y> corner of the rectangle

Returns
The <-x,+y> corner of the rectangle

◆ posXNegYCorner()

const Point & posXNegYCorner ( ) const

Returns the <+x,-y> corner of the rectangle

Returns
The <+x,-y> corner of the rectangle

◆ posXPosYCorner()

const Point & posXPosYCorner ( ) const

Returns the <+x,+y> corner of the rectangle

Returns
The <+x,+y> corner of the rectangle

◆ xLength()

double xLength ( ) const

Returns the length along the x-axis of the rectangle

Returns
The length along the x-axis of the rectangle

◆ xMax()

double xMax ( ) const

Gets the maximum x value of the rectangle

return max x value

◆ xMin()

double xMin ( ) const

Gets the minimum x value of the rectangle

return min x value

◆ yLength()

double yLength ( ) const

Returns the length along the y-axis of the rectangle

Returns
The length along the y-axis of the rectangle

◆ yMax()

double yMax ( ) const

Gets the maximum y value of the rectangle

return max y value

◆ yMin()

double yMin ( ) const

Gets the minimum y value of the rectangle

return min y value


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