cgal/Packages/Generator/include/CGAL/Random_polygon_traits_2.h

106 lines
3.1 KiB
C++

// ======================================================================
//
// Copyright (c) 2000 The CGAL Consortium
//
// This software and related documentation is part of an INTERNAL release
// of the Computational Geometry Algorithms Library (CGAL). It is not
// intended for general use.
//
// ----------------------------------------------------------------------
//
// release : $CGAL_Revision: CGAL-2.2-I-12 $
// release_date : $CGAL_Date: 2000/04/07 $
//
// file : include/CGAL/Random_polygon_traits_2.h
// package : $CGAL_Package $
// chapter : Geometric Object Generators
//
// revision : 1.0
// revision_date : 19 April 2000
//
// author(s) : Susan Hert <hert@mpi-sb.mpg.de>
//
// coordinator : ETH Zurich (Bernd Gaertner <gaertner@inf.ethz.ch>)
//
// implementation: Random Simple Polygon Traits
// ======================================================================
#ifndef CGAL_RANDOM_POLYGON_TRAITS_2_H
#define CGAL_RANDOM_POLYGON_TRAITS_2_H
#include <CGAL/Direction_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/Segment_2.h>
#include <CGAL/Vector_2.h>
#include <CGAL/number_utils.h>
#include <CGAL/predicates_on_points_2.h>
#include <CGAL/predicate_classes_2.h>
#include <CGAL/Segment_2_Segment_2_intersection.h>
CGAL_BEGIN_NAMESPACE
//-----------------------------------------------------------------------//
// Random_polygon_traits_2
//-----------------------------------------------------------------------//
template <class R_>
class Random_polygon_traits_2
{
public:
typedef R_ R;
typedef typename R::FT FT;
typedef Point_2<R> Point_2;
typedef ::CGAL::Segment_2<R> Segment_2;
typedef ::CGAL::Vector_2<R> Vector_2;
typedef ::CGAL::p_Less_yx<Point_2> Less_yx;
bool lexicographically_yx_smaller_or_equal(const Point_2& p,
const Point_2& q) const
{
return ::CGAL::lexicographically_yx_smaller_or_equal(p,q);
}
FT cross_product_2(const Vector_2& p, const Vector_2& q) const
{
return p.x() * q.y() - q.x() * p.y();
// there should be multiple versions of this function
// to distinguish between cartesian and homogeneous coordinates
// (for efficiency reasons)
}
bool is_negative(const FT& x) const
{
return CGAL_NTS is_negative(x);
}
bool do_intersect(const Point_2& p1,
const Point_2& q1,
const Point_2& p2,
const Point_2& q2) const
{
return ::CGAL::do_intersect(Segment_2(p1,q1), Segment_2(p2,q2));
}
Comparison_result compare_x(const Point_2 &p, const Point_2 &q) const
{
return ::CGAL::compare_x(p, q);
}
Comparison_result compare_y(const Point_2 &p, const Point_2 &q) const
{
return ::CGAL::compare_y(p, q);
}
bool have_equal_direction(const Vector_2& v1,
const Vector_2& v2 ) const
{
return ::CGAL::Direction_2<R>(v1) == ::CGAL::Direction_2<R>(v2);
}
};
CGAL_END_NAMESPACE
#endif // CGAL_RANDOM_POLYGON_TRAITS_2_H