CGAL 5.6.3 - 2D and 3D Linear Geometry Kernel

Loading...
Searching...
No Matches
Kernel_23/points_and_segment.cpp
#include <iostream>
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Segment_2 Segment_2;
int main()
{
Point_2 p(1,1), q(10,10);
std::cout << "p = " << p << std::endl;
std::cout << "q = " << q.x() << " " << q.y() << std::endl;
std::cout << "sqdist(p,q) = "
<< CGAL::squared_distance(p,q) << std::endl;
Segment_2 s(p,q);
Point_2 m(5, 9);
std::cout << "m = " << m << std::endl;
std::cout << "sqdist(Segment_2(p,q), m) = "
<< CGAL::squared_distance(s,m) << std::endl;
std::cout << "p, q, and m ";
switch (CGAL::orientation(p,q,m)){
case CGAL::COLLINEAR:
std::cout << "are collinear\n";
break;
case CGAL::LEFT_TURN:
std::cout << "make a left turn\n";
break;
case CGAL::RIGHT_TURN:
std::cout << "make a right turn\n";
break;
}
std::cout << " midpoint(p,q) = " << CGAL::midpoint(p,q) << std::endl;
return 0;
}
Kernel::Point_2
A type representing points in two dimensions.
Definition: GeomObjects.h:362
Kernel::Segment_2
A type representing segments in two dimensions.
Definition: GeomObjects.h:517
CGAL::orientation
Orientation orientation(ForwardIterator first, ForwardIterator last)
CGAL::squared_distance
FT squared_distance(Point_d< R > p, Point_d< R > q)
CGAL::midpoint
Point_d< R > midpoint(const Point_d< R > &p, const Point_d< R > &q)
CGAL::RIGHT_TURN
const CGAL::Orientation RIGHT_TURN
Definition: enum.h:113
CGAL::LEFT_TURN
const CGAL::Orientation LEFT_TURN
Definition: enum.h:104
CGAL::COLLINEAR
const CGAL::Orientation COLLINEAR
Definition: enum.h:95
Kernel
Definition: FunctionObjectConcepts.h:2
CGAL::Simple_cartesian
A model for a Kernel using Cartesian coordinates to represent the geometric objects.
Definition: Simple_cartesian.h:31