CGAL 5.2.4 - 2D and 3D Linear Geometry Kernel
|
#include <CGAL/Point_2.h>
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<NT>
, the two types are the same. For the kernel model Homogeneous<NT>
, Kernel::RT
is equal to NT
, and Kernel::FT
is equal to Quotient<NT>
.
Example
The following declaration creates two points with Cartesian double coordinates.
The variable p
is uninitialized and should first be used on the left hand side of an assignment.
Hashable
if Kernel
is a cartesian kernel and if Kernel::FT
is Hashable
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() . | |
bool | operator> (const Point_2< Kernel > &p, const Point_2< Kernel > &q) |
returns true iff p is lexicographically greater than q . | |
bool | operator<= (const Point_2< Kernel > &p, const Point_2< Kernel > &q) |
returns true iff p is lexicographically smaller or equal to q . | |
bool | operator>= (const Point_2< Kernel > &p, const Point_2< Kernel > &q) |
returns true iff p is lexicographically greater or equal to q . | |
Vector_2< Kernel > | operator- (const Point_2< Kernel > &p, const Point_2< Kernel > &q) |
returns the difference vector between q and p . More... | |
Point_2< Kernel > | operator+ (const Point_2< Kernel > &p, const Vector_2< Kernel > &v) |
returns the point obtained by translating p by the vector v . | |
Point_2< Kernel > | operator- (const Point_2< Kernel > &p, const Vector_2< Kernel > &v) |
returns the point obtained by translating p by the vector -v . | |
Types | |
typedef unspecified_type | Cartesian_const_iterator |
An iterator for enumerating the Cartesian coordinates of a point. | |
Creation | |
Point_2 (const Origin &ORIGIN) | |
introduces a variable p with Cartesian coordinates \( (0,0)\). | |
Point_2 (int x, int y) | |
introduces a point p initialized to (x,y) . | |
Point_2 (double x, double y) | |
introduces a point p initialized to (x,y) provided RT supports construction from double . | |
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) . | |
Point_2 (const Kernel::Weighted_point_2 &wp) | |
introduces a point from a weighted point. 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... | |
Point_2< Kernel > & | operator+= (const Vector_2< Kernel > &v) |
translates the point by the vector v . | |
Point_2< Kernel > & | operator-= (const Vector_2< Kernel > &v) |
translates the point by the vector -v . | |
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 lose information with the homogeneous representation, because the | |
Kernel::RT | hx () const |
returns the homogeneous \( x\) coordinate. | |
Kernel::RT | hy () const |
returns the homogeneous \( y\) coordinate. | |
Kernel::RT | hw () const |
returns the homogenizing coordinate. | |
Kernel::FT | x () const |
returns the Cartesian \( x\) coordinate, that is hx() /hw() . | |
Kernel::FT | y () const |
returns the Cartesian \( y\) coordinate, that is hy() /hw() . | |
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 . More... | |
Kernel::FT | cartesian (int i) const |
returns the i'th Cartesian coordinate of p . 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. | |
Cartesian_const_iterator | cartesian_end () const |
returns an off the end iterator to the Cartesian coordinates of p . | |
int | dimension () const |
returns the dimension (the constant 2). | |
Bbox_2 | bbox () const |
returns a bounding box containing p . | |
Point_2< Kernel > | transform (const Aff_transformation_2< Kernel > &t) const |
returns the point obtained by applying t on p . | |
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)
.
hw
\( \neq\) Kernel::RT(0)
.
|
explicit |
introduces a point from a weighted point.
explicit
keyword is used to avoid accidental implicit conversions between Point_2 and Weighted_point_2. Kernel::FT CGAL::Point_2< Kernel >::cartesian | ( | int | i | ) | const |
returns the i'th Cartesian coordinate of p
.
Kernel::RT CGAL::Point_2< Kernel >::homogeneous | ( | int | i | ) | const |
returns the i'th homogeneous coordinate of p
.
bool CGAL::Point_2< Kernel >::operator!= | ( | const Point_2< Kernel > & | q | ) | const |
Test for inequality.
The point can be compared with ORIGIN
.
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
.
Kernel::FT CGAL::Point_2< Kernel >::operator[] | ( | int | i | ) | const |
returns cartesian(i)
.