feisty meow concerns codebase  2.140
geometric::rectangle< numeric_type > Class Template Reference

Represents a geometric rectangle. More...

#include <rectangle.h>

Inheritance diagram for geometric::rectangle< numeric_type >:
Collaboration diagram for geometric::rectangle< numeric_type >:

Public Member Functions

 rectangle (const point< numeric_type > &vertex_1, const point< numeric_type > &vertex_2)
 
 rectangle (numeric_type x_1=0, numeric_type y_1=0, numeric_type x_2=0, numeric_type y_2=0)
 
numeric_type height () const
 
numeric_type width () const
 
rectangle order () const
 Re-orders the vertices of the line to be increasing. More...
 
point< numeric_type > top_left () const
 
point< numeric_type > bottom_left () const
 
point< numeric_type > top_right () const
 
point< numeric_type > bottom_right () const
 returns the appropriate point as represented by our rectangle. More...
 
numeric_type minimum_x () const
 Return the smallest x from the points in the rectangle. More...
 
numeric_type minimum_y () const
 Return the smallest y from the points in the rectangle. More...
 
numeric_type maximum_x () const
 Return the largest x from the points in the rectangle. More...
 
numeric_type maximum_y () const
 Return the largest y from the points in the rectangle. More...
 
point< numeric_type > center () const
 Returns the point at the center of the rectangle. More...
 
bool inside (const point< numeric_type > &to_check) const
 Returns true if ‘to_check’ is inside ‘this’ rectangle. More...
 
bool operator== (const rectangle &to_compare) const
 Returns true if ‘to_compare’ has vertices equal to ‘this’. More...
 
rectangle operator+ (const point< numeric_type > &to_add) const
 Returns the rectangle resulting from adding a point to its vertices. More...
 
rectangle operator- (const point< numeric_type > &to_subtract) const
 Returns the rectangle resulting from subtracting "to_subtract". More...
 
rectangleoperator+= (const point< numeric_type > &to_add)
 Adds the point "to_add" to our vertices. More...
 
rectangleoperator-= (const point< numeric_type > &to_subtract)
 Subtracts the point "to_add" to our vertices. More...
 
void encompass (const rectangle &to_adjust_to)
 Finds the largest dimension needed to contain all rectangles passed in. More...
 
bool intersect (const rectangle &r2) const
 Returns true if ‘this’ & ‘r2’ cover any common points. More...
 
bool disjoint (const rectangle &r2) const
 Returns true if ‘this’ & ‘r2’ have mutually exclusive extents. More...
 
bool join_intersecting (const rectangle &r2, rectangle &result)
 Sets "result" to encompass this and "r2" if they intersect. More...
 
bool intersection (const rectangle &r2, rectangle &result)
 Sets "result" to the intersection of this and "r2". More...
 
basis::astring text_form () const
 Prints out the contents of the rectangle. More...
 
bool from_text (const basis::astring &text)
 Returns true if the "text" is parsed into this rectangle. More...
 
point< numeric_type > vertex_1 () const
 
point< numeric_type > vertex_2 () const
 
void vertex_1 (const point< numeric_type > &to_set)
 
void vertex_2 (const point< numeric_type > &to_set)
 
virtual int packed_size () const
 Estimates the space needed for the packed structure. More...
 
virtual void pack (basis::byte_array &packed_form) const
 Creates a packed form of the packable object in "packed_form". More...
 
virtual bool unpack (basis::byte_array &packed_form)
 Restores the packable from the "packed_form". More...
 

Protected Attributes

point< numeric_type > _vertex_1
 
point< numeric_type > _vertex_2
 

Detailed Description

template<class numeric_type>
class geometric::rectangle< numeric_type >

Represents a geometric rectangle.

Definition at line 27 of file rectangle.h.

Constructor & Destructor Documentation

◆ rectangle() [1/2]

template<class numeric_type >
geometric::rectangle< numeric_type >::rectangle ( const point< numeric_type > &  vertex_1,
const point< numeric_type > &  vertex_2 
)

Definition at line 139 of file rectangle.h.

◆ rectangle() [2/2]

template<class numeric_type >
geometric::rectangle< numeric_type >::rectangle ( numeric_type  x_1 = 0,
numeric_type  y_1 = 0,
numeric_type  x_2 = 0,
numeric_type  y_2 = 0 
)

Definition at line 143 of file rectangle.h.

Member Function Documentation

◆ bottom_left()

template<class numeric_type >
point< numeric_type > geometric::rectangle< numeric_type >::bottom_left

◆ bottom_right()

template<class numeric_type >
point< numeric_type > geometric::rectangle< numeric_type >::bottom_right

returns the appropriate point as represented by our rectangle.

note that these are with respect to a normal cartesian coordinate system. if you want points for a screen based coordinate system (with the origin in the top left), then bottom_left and top_right return the appropriate bounding points for that rectangle.

Definition at line 221 of file rectangle.h.

References geometric::rectangle< numeric_type >::vertex_1(), and geometric::rectangle< numeric_type >::vertex_2().

Referenced by geometric::screen_rectangle::top_right().

◆ center()

template<class numeric_type >
point< numeric_type > geometric::rectangle< numeric_type >::center

Returns the point at the center of the rectangle.

Definition at line 228 of file rectangle.h.

◆ disjoint()

template<class numeric_type >
bool geometric::rectangle< numeric_type >::disjoint ( const rectangle< numeric_type > &  r2) const

◆ encompass()

template<class numeric_type >
void geometric::rectangle< numeric_type >::encompass ( const rectangle< numeric_type > &  to_adjust_to)

Finds the largest dimension needed to contain all rectangles passed in.

The original dimension of ‘this’ rectangle is compared with all subsequent rectangles passed to adjust_dimension, and it is modified (joined with ‘to_adjust_to’) if the extent of ‘to_adjust_to’ is greater or lesser than the current extent of ‘this’ rectangle.

Definition at line 305 of file rectangle.h.

References geometric::rectangle< numeric_type >::_vertex_1, and geometric::rectangle< numeric_type >::_vertex_2.

Referenced by geometric::rectangle< numeric_type >::join_intersecting().

◆ from_text()

template<class numeric_type >
bool geometric::rectangle< numeric_type >::from_text ( const basis::astring text)

Returns true if the "text" is parsed into this rectangle.

Definition at line 359 of file rectangle.h.

References basis::astring::convert(), geometric::crop_non_numeric(), geometric::crop_numeric(), and geometric::numeric_specifier().

◆ height()

template<class numeric_type >
numeric_type geometric::rectangle< numeric_type >::height

Definition at line 164 of file rectangle.h.

References basis::absolute_value().

◆ inside()

template<class numeric_type >
bool geometric::rectangle< numeric_type >::inside ( const point< numeric_type > &  to_check) const

◆ intersect()

template<class numeric_type >
bool geometric::rectangle< numeric_type >::intersect ( const rectangle< numeric_type > &  r2) const

Returns true if ‘this’ & ‘r2’ cover any common points.

Definition at line 328 of file rectangle.h.

◆ intersection()

template<class numeric_type >
bool geometric::rectangle< numeric_type >::intersection ( const rectangle< numeric_type > &  r2,
rectangle< numeric_type > &  result 
)

Sets "result" to the intersection of this and "r2".

If ‘this’ and ‘r2’ intersect, then ‘result’ is set to their intersecting extent and true is returned. If not, then false is returned and ‘result’ is undefined.

Definition at line 341 of file rectangle.h.

References basis::maximum(), geometric::rectangle< numeric_type >::maximum_x(), geometric::rectangle< numeric_type >::maximum_y(), basis::minimum(), geometric::rectangle< numeric_type >::minimum_x(), and geometric::rectangle< numeric_type >::minimum_y().

◆ join_intersecting()

template<class numeric_type >
bool geometric::rectangle< numeric_type >::join_intersecting ( const rectangle< numeric_type > &  r2,
rectangle< numeric_type > &  result 
)

Sets "result" to encompass this and "r2" if they intersect.

If ‘this’ and ‘r2’ intersect, ‘result’ is adjusted to their dimension and true is returned. If not, false is returned and ‘result’ is undefined.

Definition at line 332 of file rectangle.h.

References geometric::rectangle< numeric_type >::encompass().

◆ maximum_x()

template<class numeric_type >
numeric_type geometric::rectangle< numeric_type >::maximum_x

Return the largest x from the points in the rectangle.

Definition at line 180 of file rectangle.h.

References basis::maximum().

Referenced by geometric::rectangle< numeric_type >::disjoint(), geometric::rectangle< numeric_type >::intersection(), and geometric::rectangle< numeric_type >::operator==().

◆ maximum_y()

template<class numeric_type >
numeric_type geometric::rectangle< numeric_type >::maximum_y

Return the largest y from the points in the rectangle.

Definition at line 184 of file rectangle.h.

References basis::maximum().

Referenced by geometric::rectangle< numeric_type >::disjoint(), geometric::rectangle< numeric_type >::intersection(), and geometric::rectangle< numeric_type >::operator==().

◆ minimum_x()

template<class numeric_type >
numeric_type geometric::rectangle< numeric_type >::minimum_x

Return the smallest x from the points in the rectangle.

Definition at line 172 of file rectangle.h.

References basis::minimum().

Referenced by geometric::rectangle< numeric_type >::disjoint(), geometric::rectangle< numeric_type >::intersection(), and geometric::rectangle< numeric_type >::operator==().

◆ minimum_y()

template<class numeric_type >
numeric_type geometric::rectangle< numeric_type >::minimum_y

Return the smallest y from the points in the rectangle.

Definition at line 176 of file rectangle.h.

References basis::minimum().

Referenced by geometric::rectangle< numeric_type >::disjoint(), geometric::rectangle< numeric_type >::intersection(), and geometric::rectangle< numeric_type >::operator==().

◆ operator+()

template<class numeric_type >
rectangle< numeric_type > geometric::rectangle< numeric_type >::operator+ ( const point< numeric_type > &  to_add) const

Returns the rectangle resulting from adding a point to its vertices.

Definition at line 265 of file rectangle.h.

◆ operator+=()

template<class numeric_type >
rectangle< numeric_type > & geometric::rectangle< numeric_type >::operator+= ( const point< numeric_type > &  to_add)

Adds the point "to_add" to our vertices.

Definition at line 257 of file rectangle.h.

◆ operator-()

template<class numeric_type >
rectangle< numeric_type > geometric::rectangle< numeric_type >::operator- ( const point< numeric_type > &  to_subtract) const

Returns the rectangle resulting from subtracting "to_subtract".

Definition at line 297 of file rectangle.h.

◆ operator-=()

template<class numeric_type >
rectangle< numeric_type > & geometric::rectangle< numeric_type >::operator-= ( const point< numeric_type > &  to_subtract)

Subtracts the point "to_add" to our vertices.

Definition at line 261 of file rectangle.h.

◆ operator==()

template<class numeric_type >
bool geometric::rectangle< numeric_type >::operator== ( const rectangle< numeric_type > &  to_compare) const

◆ order()

template<class numeric_type >
rectangle< numeric_type > geometric::rectangle< numeric_type >::order

Re-orders the vertices of the line to be increasing.

Orients the vertices such that the x and y coordinates of the first vertex are respectively closer to the origin than the x and y coordinates of the second vertex (or they are equidistant).

Definition at line 188 of file rectangle.h.

References basis::flip_increasing().

◆ pack()

template<class contents >
void geometric::rectangle< contents >::pack ( basis::byte_array packed_form) const
virtual

Creates a packed form of the packable object in "packed_form".

This must append to the data in "packed_form" rather than clearing prior contents.

Implements basis::packable.

Definition at line 282 of file rectangle.h.

◆ packed_size()

template<class contents >
int geometric::rectangle< contents >::packed_size ( ) const
virtual

Estimates the space needed for the packed structure.

Implements basis::packable.

Definition at line 273 of file rectangle.h.

References basis::array< contents >::length(), and structures::pack().

◆ text_form()

template<class numeric_type >
basis::astring geometric::rectangle< numeric_type >::text_form

Prints out the contents of the rectangle.

Definition at line 352 of file rectangle.h.

References basis::astring::text_form().

◆ top_left()

template<class numeric_type >
point< numeric_type > geometric::rectangle< numeric_type >::top_left

◆ top_right()

template<class numeric_type >
point< numeric_type > geometric::rectangle< numeric_type >::top_right

◆ unpack()

template<class contents >
bool geometric::rectangle< contents >::unpack ( basis::byte_array packed_form)
virtual

Restores the packable from the "packed_form".

This object becomes the unpacked form, and therefore must lose any of its prior contents that depend on the data in "packed_form". This is up to the derived unpack function to figure out. The "packed_form" is modified by extracting all of the pieces that are used for this object; the remainder stays in "packed_form". true is returned if the unpacking was successful.

Implements basis::packable.

Definition at line 289 of file rectangle.h.

◆ vertex_1() [1/2]

template<class numeric_type >
point< numeric_type > geometric::rectangle< numeric_type >::vertex_1

◆ vertex_1() [2/2]

template<class numeric_type >
void geometric::rectangle< numeric_type >::vertex_1 ( const point< numeric_type > &  to_set)

Definition at line 156 of file rectangle.h.

◆ vertex_2() [1/2]

template<class numeric_type >
point< numeric_type > geometric::rectangle< numeric_type >::vertex_2

◆ vertex_2() [2/2]

template<class numeric_type >
void geometric::rectangle< numeric_type >::vertex_2 ( const point< numeric_type > &  to_set)

Definition at line 160 of file rectangle.h.

◆ width()

template<class numeric_type >
numeric_type geometric::rectangle< numeric_type >::width

Definition at line 168 of file rectangle.h.

References basis::absolute_value().

Member Data Documentation

◆ _vertex_1

template<class numeric_type >
point<numeric_type> geometric::rectangle< numeric_type >::_vertex_1
protected

◆ _vertex_2

template<class numeric_type >
point<numeric_type> geometric::rectangle< numeric_type >::_vertex_2
protected

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