some work on util
This commit is contained in:
parent
d387314715
commit
223ffa6f6b
1 changed files with 33 additions and 1 deletions
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <sstream>
|
||||||
#include "util/Misc.h"
|
#include "util/Misc.h"
|
||||||
#include "util/geo/Box.h"
|
#include "util/geo/Box.h"
|
||||||
#include "util/geo/Line.h"
|
#include "util/geo/Line.h"
|
||||||
|
@ -252,6 +252,18 @@ inline bool intersects(const Point<T>& p, const Line<T>& l) {
|
||||||
return intersects(l, p);
|
return intersects(l, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// _____________________________________________________________________________
|
||||||
|
template <typename T>
|
||||||
|
inline bool intersects(const Polygon<T>& l, const Point<T>& p) {
|
||||||
|
return contains(l, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// _____________________________________________________________________________
|
||||||
|
template <typename T>
|
||||||
|
inline bool intersects(const Point<T>& p, const Polygon<T>& l) {
|
||||||
|
return intersects(l, p);
|
||||||
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool intersects(const Box<T>& b1, const Box<T>& b2) {
|
inline bool intersects(const Box<T>& b1, const Box<T>& b2) {
|
||||||
|
@ -284,6 +296,26 @@ inline bool intersects(const LineSegment<T>& ls, const Box<T>& b) {
|
||||||
return contains(ls, b);
|
return contains(ls, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// _____________________________________________________________________________
|
||||||
|
template <typename T>
|
||||||
|
inline bool intersects(const LineSegment<T>& ls, const Polygon<T>& p) {
|
||||||
|
for (size_t i = 1; i < p.getOuter().size(); i++) {
|
||||||
|
if (intersects(LineSegment<T>(p.getOuter()[i - 1], p.getOuter()[i]), ls))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intersects(LineSegment<T>(p.getOuter().back(), p.getOuter().front()), ls))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return contains(ls, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// _____________________________________________________________________________
|
||||||
|
template <typename T>
|
||||||
|
inline bool intersects(const Polygon<T>& p, const LineSegment<T>& ls) {
|
||||||
|
return intersects(ls, p);
|
||||||
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool intersects(const Box<T>& b, const LineSegment<T>& ls) {
|
inline bool intersects(const Box<T>& b, const LineSegment<T>& ls) {
|
||||||
|
|
Loading…
Reference in a new issue