CGAL 6.0 - 2D and 3D Linear Geometry Kernel
Searching...
No Matches
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.

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.

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 (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).

Iso_rectangle_2 (const Bbox_2 &bbox)
If Kernel::RT is constructible from double, introduces an iso-oriented rectangle from bbox.

## 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.

bool operator!= (const Iso_rectangle_2< Kernel > &r2) const
Test for inequality.

Point_2< Kernelvertex (int i) const
returns the i'th vertex modulo 4 of r in counterclockwise order, starting with the lower left vertex.

Point_2< Kerneloperator[] (int i) const
returns vertex(i).

Point_2< Kernelmin () const
returns the lower left vertex of r (= vertex(0)).

Point_2< Kernelmax () const
returns the upper right vertex of r (= vertex(2)).

Kernel::FT xmin () const
returns the $$x$$ coordinate of lower left vertex of r.

Kernel::FT ymin () const
returns the $$y$$ coordinate of lower left vertex of r.

Kernel::FT xmax () const
returns the $$x$$ coordinate of upper right vertex of r.

Kernel::FT ymax () const
returns the $$y$$ coordinate of upper right vertex of r.

Kernel::FT min_coord (int i) const
returns the i'th Cartesian coordinate of the lower left vertex of r.

Kernel::FT max_coord (int i) const
returns the i'th Cartesian coordinate of the upper right vertex of r.

## Predicates

bool is_degenerate () const
r is degenerate, if all vertices are collinear.

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.

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.

Bbox_2 bbox () const
returns a bounding box containing r.

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.

## ◆ 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.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ 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().
Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ 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.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ 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 != 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.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ bbox()

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

returns a bounding box containing r.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ max()

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

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

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ 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 <= i <= 1.
Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ min()

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

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

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ 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 <= i <= 1.
Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ operator[]()

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

returns vertex(i).

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ 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.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ xmax()

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

returns the $$x$$ coordinate of upper right vertex of r.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ xmin()

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

returns the $$x$$ coordinate of lower left vertex of r.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ ymax()

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

returns the $$y$$ coordinate of upper right vertex of r.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.

## ◆ ymin()

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

returns the $$y$$ coordinate of lower left vertex of r.

Exactness
This construction is trivial and therefore always exact in Exact_predicates_inexact_constructions_kernel.