CGAL 5.1 - 2D and 3D Linear Geometry Kernel
CGAL::Iso_rectangle_2< Kernel > Class Template Reference

#include <CGAL/Iso_rectangle_2.h>

Definition

template<typename Kernel>
class CGAL::Iso_rectangle_2< Kernel >

An object r of the data type Iso_rectangle_2 is a rectangle in the Euclidean plane \( \E^2\) with sides parallel to the \( x\) and \( y\) axis of the coordinate system.

Although they are represented in a canonical form by only two vertices, namely the lower left and the upper right vertex, we provide functions for "accessing" the other vertices as well. The vertices are returned in counterclockwise order.

Iso-oriented rectangles and bounding boxes are quite similar. The difference however is that bounding boxes have always double coordinates, whereas the coordinate type of an iso-oriented rectangle is chosen by the user.

Is Model Of:

Kernel::IsoRectangle_2

Hashable if Kernel is a cartesian kernel and if Kernel::FT is Hashable

Creation

 Iso_rectangle_2 (const Point_2< Kernel > &p, const Point_2< Kernel > &q)
 introduces an iso-oriented rectangle r with diagonal opposite vertices p and q. More...
 
 Iso_rectangle_2 (const Point_2< Kernel > &p, const Point_2< Kernel > &q, int)
 introduces an iso-oriented rectangle r with diagonal opposite vertices p and q. More...
 
 Iso_rectangle_2 (const Point_2< Kernel > &left, const Point_2< Kernel > &right, const Point_2< Kernel > &bottom, const Point_2< Kernel > &top)
 introduces an iso-oriented rectangle r whose minimal \( x\) coordinate is the one of left, the maximal \( x\) coordinate is the one of right, the minimal \( y\) coordinate is the one of bottom, the maximal \( y\) coordinate is the one of top. More...
 
 Iso_rectangle_2 (const Kernel::RT &min_hx, const Kernel::RT &min_hy, const Kernel::RT &max_hx, const Kernel::RT &max_hy, const Kernel::RT &hw=RT(1))
 introduces an iso-oriented rectangle r with diagonal opposite vertices (min_hx/hw, min_hy/hw) and (max_hx/hw, max_hy/hw). More...
 
 Iso_rectangle_2 (const Bbox_2 &bbox)
 If Kernel::RT is constructible from double, introduces an iso-oriented rectangle from bbox. More...
 

Operations

bool operator== (const Iso_rectangle_2< Kernel > &r2) const
 Test for equality: two iso-oriented rectangles are equal, iff their lower left and their upper right vertices are equal. More...
 
bool operator!= (const Iso_rectangle_2< Kernel > &r2) const
 Test for inequality. More...
 
Point_2< Kernelvertex (int i) const
 returns the i'th vertex modulo 4 of r in counterclockwise order, starting with the lower left vertex. More...
 
Point_2< Kerneloperator[] (int i) const
 returns vertex(i). More...
 
Point_2< Kernelmin () const
 returns the lower left vertex of r (= vertex(0)). More...
 
Point_2< Kernelmax () const
 returns the upper right vertex of r (= vertex(2)). More...
 
Kernel::FT xmin () const
 returns the \( x\) coordinate of lower left vertex of r. More...
 
Kernel::FT ymin () const
 returns the \( y\) coordinate of lower left vertex of r. More...
 
Kernel::FT xmax () const
 returns the \( x\) coordinate of upper right vertex of r. More...
 
Kernel::FT ymax () const
 returns the \( y\) coordinate of upper right vertex of r. More...
 
Kernel::FT min_coord (int i) const
 returns the i'th Cartesian coordinate of the lower left vertex of r. More...
 
Kernel::FT max_coord (int i) const
 returns the i'th Cartesian coordinate of the upper right vertex of r. More...
 

Predicates

bool is_degenerate () const
 r is degenerate, if all vertices are collinear. More...
 
Bounded_side bounded_side (const Point_2< Kernel > &p) const
 returns either ON_UNBOUNDED_SIDE, ON_BOUNDED_SIDE, or the constant ON_BOUNDARY, depending on where point p is. More...
 
bool has_on_boundary (const Point_2< Kernel > &p) const
 
bool has_on_bounded_side (const Point_2< Kernel > &p) const
 
bool has_on_unbounded_side (const Point_2< Kernel > &p) const
 

Miscellaneous

Kernel::FT area () const
 returns the area of r. More...
 
Bbox_2 bbox () const
 returns a bounding box containing r. More...
 
Iso_rectangle_2< Kerneltransform (const Aff_transformation_2< Kernel > &t) const
 returns the iso-oriented rectangle obtained by applying t on the lower left and the upper right corner of r. More...
 

Constructor & Destructor Documentation

◆ Iso_rectangle_2() [1/5]

template<typename Kernel >
CGAL::Iso_rectangle_2< Kernel >::Iso_rectangle_2 ( const Point_2< Kernel > &  p,
const Point_2< Kernel > &  q 
)

introduces an iso-oriented rectangle r with diagonal opposite vertices p and q.

Note that the object is brought in the canonical form.

◆ Iso_rectangle_2() [2/5]

template<typename Kernel >
CGAL::Iso_rectangle_2< Kernel >::Iso_rectangle_2 ( const Point_2< Kernel > &  p,
const Point_2< Kernel > &  q,
int   
)

introduces an iso-oriented rectangle r with diagonal opposite vertices p and q.

The int argument value is only used to distinguish the two overloaded functions.

Precondition
p.x()<=q.x() and p.y()<=q.y().

◆ Iso_rectangle_2() [3/5]

template<typename Kernel >
CGAL::Iso_rectangle_2< Kernel >::Iso_rectangle_2 ( const Point_2< Kernel > &  left,
const Point_2< Kernel > &  right,
const Point_2< Kernel > &  bottom,
const Point_2< Kernel > &  top 
)

introduces an iso-oriented rectangle r whose minimal \( x\) coordinate is the one of left, the maximal \( x\) coordinate is the one of right, the minimal \( y\) coordinate is the one of bottom, the maximal \( y\) coordinate is the one of top.

◆ Iso_rectangle_2() [4/5]

template<typename Kernel >
CGAL::Iso_rectangle_2< Kernel >::Iso_rectangle_2 ( const Kernel::RT min_hx,
const Kernel::RT min_hy,
const Kernel::RT max_hx,
const Kernel::RT max_hy,
const Kernel::RT hw = RT(1) 
)

introduces an iso-oriented rectangle r with diagonal opposite vertices (min_hx/hw, min_hy/hw) and (max_hx/hw, max_hy/hw).

Precondition
hw \( \neq\) 0.

◆ Iso_rectangle_2() [5/5]

template<typename Kernel >
CGAL::Iso_rectangle_2< Kernel >::Iso_rectangle_2 ( const Bbox_2 bbox)

If Kernel::RT is constructible from double, introduces an iso-oriented rectangle from bbox.

Member Function Documentation

◆ area()

template<typename Kernel >
Kernel::FT CGAL::Iso_rectangle_2< Kernel >::area ( ) const

returns the area of r.

◆ bbox()

template<typename Kernel >
Bbox_2 CGAL::Iso_rectangle_2< Kernel >::bbox ( ) const

returns a bounding box containing r.

◆ bounded_side()

template<typename Kernel >
Bounded_side CGAL::Iso_rectangle_2< Kernel >::bounded_side ( const Point_2< Kernel > &  p) const

returns either ON_UNBOUNDED_SIDE, ON_BOUNDED_SIDE, or the constant ON_BOUNDARY, depending on where point p is.

◆ has_on_boundary()

template<typename Kernel >
bool CGAL::Iso_rectangle_2< Kernel >::has_on_boundary ( const Point_2< Kernel > &  p) const

◆ has_on_bounded_side()

template<typename Kernel >
bool CGAL::Iso_rectangle_2< Kernel >::has_on_bounded_side ( const Point_2< Kernel > &  p) const

◆ has_on_unbounded_side()

template<typename Kernel >
bool CGAL::Iso_rectangle_2< Kernel >::has_on_unbounded_side ( const Point_2< Kernel > &  p) const

◆ is_degenerate()

template<typename Kernel >
bool CGAL::Iso_rectangle_2< Kernel >::is_degenerate ( ) const

r is degenerate, if all vertices are collinear.

◆ max()

template<typename Kernel >
Point_2<Kernel> CGAL::Iso_rectangle_2< Kernel >::max ( ) const

returns the upper right vertex of r (= vertex(2)).

◆ max_coord()

template<typename Kernel >
Kernel::FT CGAL::Iso_rectangle_2< Kernel >::max_coord ( int  i) const

returns the i'th Cartesian coordinate of the upper right vertex of r.

Precondition
\( 0 \leq i \leq1\).

◆ min()

template<typename Kernel >
Point_2<Kernel> CGAL::Iso_rectangle_2< Kernel >::min ( ) const

returns the lower left vertex of r (= vertex(0)).

◆ min_coord()

template<typename Kernel >
Kernel::FT CGAL::Iso_rectangle_2< Kernel >::min_coord ( int  i) const

returns the i'th Cartesian coordinate of the lower left vertex of r.

Precondition
\( 0 \leq i \leq1\).

◆ operator!=()

template<typename Kernel >
bool CGAL::Iso_rectangle_2< Kernel >::operator!= ( const Iso_rectangle_2< Kernel > &  r2) const

Test for inequality.

◆ operator==()

template<typename Kernel >
bool CGAL::Iso_rectangle_2< Kernel >::operator== ( const Iso_rectangle_2< Kernel > &  r2) const

Test for equality: two iso-oriented rectangles are equal, iff their lower left and their upper right vertices are equal.

◆ operator[]()

template<typename Kernel >
Point_2<Kernel> CGAL::Iso_rectangle_2< Kernel >::operator[] ( int  i) const

returns vertex(i).

◆ transform()

template<typename Kernel >
Iso_rectangle_2<Kernel> CGAL::Iso_rectangle_2< Kernel >::transform ( const Aff_transformation_2< Kernel > &  t) const

returns the iso-oriented rectangle obtained by applying t on the lower left and the upper right corner of r.

Precondition
The angle at a rotation must be a multiple of \( \pi/2\), otherwise the resulting rectangle does not have the same side length. Note that rotating about an arbitrary angle can even result in a degenerate iso-oriented rectangle.

◆ vertex()

template<typename Kernel >
Point_2<Kernel> CGAL::Iso_rectangle_2< Kernel >::vertex ( int  i) const

returns the i'th vertex modulo 4 of r in counterclockwise order, starting with the lower left vertex.

◆ xmax()

template<typename Kernel >
Kernel::FT CGAL::Iso_rectangle_2< Kernel >::xmax ( ) const

returns the \( x\) coordinate of upper right vertex of r.

◆ xmin()

template<typename Kernel >
Kernel::FT CGAL::Iso_rectangle_2< Kernel >::xmin ( ) const

returns the \( x\) coordinate of lower left vertex of r.

◆ ymax()

template<typename Kernel >
Kernel::FT CGAL::Iso_rectangle_2< Kernel >::ymax ( ) const

returns the \( y\) coordinate of upper right vertex of r.

◆ ymin()

template<typename Kernel >
Kernel::FT CGAL::Iso_rectangle_2< Kernel >::ymin ( ) const

returns the \( y\) coordinate of lower left vertex of r.