Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Ray.h
Go to the documentation of this file.
1
31#pragma once
32
33#ifdef OGDF_INCLUDE_CGAL
34
38
39# include <CGAL/IO/io.h>
40# include <CGAL/Ray_2.h>
41
42namespace ogdf {
43namespace internal {
44namespace gcm {
45namespace geometry {
46using namespace tools;
47
48template<typename kernel>
49using Ray_t = CGAL::Ray_2<kernel>;
50
51template<typename kernel, typename type>
52inline Point_t<kernel> rel_point_at(const Ray_t<kernel>& r, const type l) {
53 return r.source() + r.to_vector() * l;
54}
55
56template<typename kernel>
57inline typename kernel::FT squared_convex_parameter_directed(const Ray_t<kernel>& r,
58 const Point_t<kernel>& p) {
59 OGDF_ASSERT(r.has_on(p));
60 return (r.source() - p).squared_length() / r.to_vector().squared_length();
61}
62
63template<typename kernel>
64inline Point_t<kernel> intersect(const Line_t<kernel>& l, const Ray_t<kernel>& r) {
65 OGDF_ASSERT(!l.is_degenerate());
66 OGDF_ASSERT(!r.is_degenerate());
67 auto result = CGAL::intersection(l, r);
68 if (!result) {
69 return Point_t<kernel>(std::numeric_limits<unsigned int>::max(),
70 std::numeric_limits<unsigned int>::max());
71 }
72 Point_t<kernel> intersection;
73 if (boost::get<Ray_t<kernel>>(&*result)) {
74 auto s = boost::get<Ray_t<kernel>>(&*result);
75 intersection = s->point(0);
76 } else {
77 intersection = *boost::get<Point_t<kernel>>(&*result);
78 }
79 return intersection;
80}
81
82} //namespace
83}
84}
85}
86
87#endif
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
int r[]
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.