\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 4.7 - 2D and 3D Linear Geometry Kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
CGAL::Point_2< Kernel > Class Template Reference

#include <CGAL/Point_2.h>

Definition

An object p of the class Point_2 is a point in the two-dimensional Euclidean plane \( \E^2\).

Remember that Kernel::RT and Kernel::FT denote a RingNumberType and a FieldNumberType, respectively. For the kernel model Cartesian<T>, the two types are the same. For the kernel model Homogeneous<T>, Kernel::RT is equal to T, and Kernel::FT is equal to Quotient<T>.

Operators

The following operations can be applied on points:

Example

The following declaration creates two points with Cartesian double coordinates.

Point_2< Cartesian<double> > p, q(1.0, 2.0);

The variable p is uninitialized and should first be used on the left hand side of an assignment.

p = q;
std::cout << p.x() << " " << p.y() << std::endl;
See also
Kernel::Point_2

Related Functions

(Note that these are not member functions.)

bool operator< (const Point_2< Kernel > &p, const Point_2< Kernel > &q)
 returns true iff p is lexicographically smaller than q, i.e. either if p.x() < q.x() or if p.x() == q.x() and p.y() < q.y(). More...
 
bool operator> (const Point_2< Kernel > &p, const Point_2< Kernel > &q)
 returns true iff p is lexicographically greater than q. More...
 
bool operator<= (const Point_2< Kernel > &p, const Point_2< Kernel > &q)
 returns true iff p is lexicographically smaller or equal to q. More...
 
bool operator>= (const Point_2< Kernel > &p, const Point_2< Kernel > &q)
 returns true iff p is lexicographically greater or equal to q. More...
 
Vector_2< Kerneloperator- (const Point_2< Kernel > &p, const Point_2< Kernel > &q)
 returns the difference vector between q and p. More...
 
Point_2< Kerneloperator+ (const Point_2< Kernel > &p, const Vector_2< Kernel > &v)
 returns the point obtained by translating p by the vector v. More...
 
Point_2< Kerneloperator- (const Point_2< Kernel > &p, const Vector_2< Kernel > &v)
 returns the point obtained by translating p by the vector -v. More...
 

Types

typedef unspecified_type Cartesian_const_iterator
 An iterator for enumerating the Cartesian coordinates of a point. More...
 

Creation

 Point_2 (const Origin &ORIGIN)
 introduces a variable p with Cartesian coordinates \( (0,0)\). More...
 
 Point_2 (int x, int y)
 introduces a point p initialized to (x,y). More...
 
 Point_2 (double x, double y)
 introduces a point p initialized to (x,y) provided RT supports construction from double. More...
 
 Point_2 (const Kernel::RT &hx, const Kernel::RT &hy, const Kernel::RT &hw=RT(1))
 introduces a point p initialized to (hx/hw,hy/hw). More...
 
 Point_2 (const Kernel::FT &x, const Kernel::FT &y)
 introduces a point p initialized to (x,y). More...
 

Operations

bool operator== (const Point_2< Kernel > &q) const
 Test for equality. More...
 
bool operator!= (const Point_2< Kernel > &q) const
 Test for inequality. More...
 

Coordinate Access

There are two sets of coordinate access functions, namely to the homogeneous and to the Cartesian coordinates.

They can be used independently from the chosen kernel model. Note that you do not loose information with the homogeneous representation, because the FieldNumberType is a quotient.

Kernel::RT hx () const
 returns the homogeneous \( x\) coordinate. More...
 
Kernel::RT hy () const
 returns the homogeneous \( y\) coordinate. More...
 
Kernel::RT hw () const
 returns the homogenizing coordinate. More...
 
Kernel::FT x () const
 returns the Cartesian \( x\) coordinate, that is hx()/hw(). More...
 
Kernel::FT y () const
 returns the Cartesian \( y\) coordinate, that is hy()/hw(). More...
 

Convenience Operations

The following operations are for convenience and for compatibility with higher dimensional points.

Again they come in a Cartesian and in a homogeneous flavor.

Kernel::RT homogeneous (int i) const
 returns the i'th homogeneous coordinate of p, starting with 0. More...
 
Kernel::FT cartesian (int i) const
 returns the i'th Cartesian coordinate of p, starting with 0. More...
 
Kernel::FT operator[] (int i) const
 returns cartesian(i). More...
 
Cartesian_const_iterator cartesian_begin () const
 returns an iterator to the Cartesian coordinates of p, starting with the 0th coordinate. More...
 
Cartesian_const_iterator cartesian_end () const
 returns an off the end iterator to the Cartesian coordinates of p. More...
 
int dimension () const
 returns the dimension (the constant 2). More...
 
Bbox_2 bbox () const
 returns a bounding box containing p. More...
 
Point_2< Kerneltransform (const Aff_transformation_2< Kernel > &t) const
 returns the point obtained by applying t on p. More...
 

Member Typedef Documentation

template<typename Kernel >
typedef unspecified_type CGAL::Point_2< Kernel >::Cartesian_const_iterator

An iterator for enumerating the Cartesian coordinates of a point.

Constructor & Destructor Documentation

template<typename Kernel >
CGAL::Point_2< Kernel >::Point_2 ( const Origin ORIGIN)

introduces a variable p with Cartesian coordinates \( (0,0)\).

template<typename Kernel >
CGAL::Point_2< Kernel >::Point_2 ( int  x,
int  y 
)

introduces a point p initialized to (x,y).

template<typename Kernel >
CGAL::Point_2< Kernel >::Point_2 ( double  x,
double  y 
)

introduces a point p initialized to (x,y) provided RT supports construction from double.

template<typename Kernel >
CGAL::Point_2< Kernel >::Point_2 ( const Kernel::RT hx,
const Kernel::RT hy,
const Kernel::RT hw = RT(1) 
)

introduces a point p initialized to (hx/hw,hy/hw).

Precondition
hw \( \neq\) Kernel::RT(0).
template<typename Kernel >
CGAL::Point_2< Kernel >::Point_2 ( const Kernel::FT x,
const Kernel::FT y 
)

introduces a point p initialized to (x,y).

Member Function Documentation

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

returns a bounding box containing p.

Note that bounding boxes are not parameterized with whatsoever.

template<typename Kernel >
Kernel::FT CGAL::Point_2< Kernel >::cartesian ( int  i) const

returns the i'th Cartesian coordinate of p, starting with 0.

Precondition
\( 0\leq i \leq1\).
template<typename Kernel >
Cartesian_const_iterator CGAL::Point_2< Kernel >::cartesian_begin ( ) const

returns an iterator to the Cartesian coordinates of p, starting with the 0th coordinate.

template<typename Kernel >
Cartesian_const_iterator CGAL::Point_2< Kernel >::cartesian_end ( ) const

returns an off the end iterator to the Cartesian coordinates of p.

template<typename Kernel >
int CGAL::Point_2< Kernel >::dimension ( ) const

returns the dimension (the constant 2).

template<typename Kernel >
Kernel::RT CGAL::Point_2< Kernel >::homogeneous ( int  i) const

returns the i'th homogeneous coordinate of p, starting with 0.

Precondition
\( 0\leq i \leq2\).
template<typename Kernel >
Kernel::RT CGAL::Point_2< Kernel >::hw ( ) const

returns the homogenizing coordinate.

template<typename Kernel >
Kernel::RT CGAL::Point_2< Kernel >::hx ( ) const

returns the homogeneous \( x\) coordinate.

template<typename Kernel >
Kernel::RT CGAL::Point_2< Kernel >::hy ( ) const

returns the homogeneous \( y\) coordinate.

template<typename Kernel >
bool CGAL::Point_2< Kernel >::operator!= ( const Point_2< Kernel > &  q) const

Test for inequality.

The point can be compared with ORIGIN.

template<typename Kernel >
bool CGAL::Point_2< Kernel >::operator== ( const Point_2< Kernel > &  q) const

Test for equality.

Two points are equal, iff their \( x\) and \( y\) coordinates are equal. The point can be compared with ORIGIN.

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

returns cartesian(i).

Precondition
\( 0\leq i \leq1\).
template<typename Kernel >
Point_2<Kernel> CGAL::Point_2< Kernel >::transform ( const Aff_transformation_2< Kernel > &  t) const

returns the point obtained by applying t on p.

template<typename Kernel >
Kernel::FT CGAL::Point_2< Kernel >::x ( ) const

returns the Cartesian \( x\) coordinate, that is hx()/hw().

template<typename Kernel >
Kernel::FT CGAL::Point_2< Kernel >::y ( ) const

returns the Cartesian \( y\) coordinate, that is hy()/hw().

Friends And Related Function Documentation

template<typename Kernel >
Vector_2< Kernel > operator- ( const Point_2< Kernel > &  p,
const Point_2< Kernel > &  q 
)
related

returns the difference vector between q and p.

You can substitute ORIGIN for either p or q, but not for both.

template<typename Kernel >
bool operator< ( const Point_2< Kernel > &  p,
const Point_2< Kernel > &  q 
)
related

returns true iff p is lexicographically smaller than q, i.e. either if p.x() < q.x() or if p.x() == q.x() and p.y() < q.y().

template<typename Kernel >
bool operator<= ( const Point_2< Kernel > &  p,
const Point_2< Kernel > &  q 
)
related

returns true iff p is lexicographically smaller or equal to q.

template<typename Kernel >
bool operator> ( const Point_2< Kernel > &  p,
const Point_2< Kernel > &  q 
)
related

returns true iff p is lexicographically greater than q.

template<typename Kernel >
bool operator>= ( const Point_2< Kernel > &  p,
const Point_2< Kernel > &  q 
)
related

returns true iff p is lexicographically greater or equal to q.