revert some changes in util

This commit is contained in:
Patrick Brosi 2018-08-10 16:51:23 +02:00
parent 8446db5c4b
commit dbceb0ef74
2 changed files with 48 additions and 17 deletions

28
src/pfaedle/Def.h Normal file
View file

@ -0,0 +1,28 @@
// Copyright 2018
// Author: Patrick Brosi
#ifndef PFAEDLE_DEF_H_
#define PFAEDLE_DEF_H_
#include "util/geo/Geo.h"
#include "util/geo/PolyLine.h"
#define __str_a(s) __str_b(s)
#define __str_b(s) #s
#define __str_c(s) s ## 1
#define __str_d(s) __str_c(s)
#if !defined(PFAEDLE_PRECISION) || (__str_d(PFAEDLE_PRECISION) == 1)
#undef PFAEDLE_PRECISION
#define PFAEDLE_PRECISION double
#endif
#define PFAEDLE_PRECISION_STR __str_a(PFAEDLE_PRECISION)
// version number from cmake version module
#define POINT util::geo::Point<PFAEDLE_PRECISION>
#define LINE util::geo::Line<PFAEDLE_PRECISION>
#define BOX util::geo::Box<PFAEDLE_PRECISION>
#define POLYLINE util::geo::PolyLine<PFAEDLE_PRECISION>
#endif // PFAEDLE_DEF_H_

View file

@ -203,8 +203,8 @@ inline Polygon<T> move(Polygon<T> geo, double x, double y) {
// _____________________________________________________________________________
template <template <typename> class Geometry, typename T>
inline std::vector<Geometry<T>> move(std::vector<Geometry<T>> multigeo, double x,
double y) {
inline std::vector<Geometry<T>> move(std::vector<Geometry<T>> multigeo,
double x, double y) {
for (size_t i = 0; i < multigeo.size(); i++)
multigeo[i] = move(multigeo[i], x, y);
return multigeo;
@ -219,15 +219,18 @@ inline Box<T> minbox() {
// _____________________________________________________________________________
template <typename T>
inline RotatedBox<T> shrink(const RotatedBox<T>& b, double d) {
double xd = b.getBox().getUpperRight().getX() - b.getBox().getLowerLeft().getX();
double yd = b.getBox().getUpperRight().getY() - b.getBox().getLowerLeft().getY();
double xd =
b.getBox().getUpperRight().getX() - b.getBox().getLowerLeft().getX();
double yd =
b.getBox().getUpperRight().getY() - b.getBox().getLowerLeft().getY();
if (xd <= 2 * d) d = xd / 2 - 1;
if (yd <= 2 * d) d = yd / 2 - 1;
Box<T> r(
Point<T>(b.getBox().getLowerLeft().getX() + d, b.getBox().getLowerLeft().getY() + d),
Point<T>(b.getBox().getUpperRight().getX() - d, b.getBox().getUpperRight().getY() - d));
Box<T> r(Point<T>(b.getBox().getLowerLeft().getX() + d,
b.getBox().getLowerLeft().getY() + d),
Point<T>(b.getBox().getUpperRight().getX() - d,
b.getBox().getUpperRight().getY() - d));
return RotatedBox<T>(r, b.getDegree(), b.getCenter());
}
@ -400,7 +403,8 @@ inline bool intersects(const LineSegment<T>& ls1, const LineSegment<T>& ls2) {
contains(ls2.first, ls1) || contains(ls2.second, ls1) ||
(((crossProd(ls1.first, ls2) < 0) ^
(crossProd(ls1.second, ls2) < 0)) &&
((crossProd(ls2.first, ls1) < 0) ^ (crossProd(ls2.second, ls1) < 0))));
((crossProd(ls2.first, ls1) < 0) ^
(crossProd(ls2.second, ls1) < 0))));
}
// _____________________________________________________________________________
@ -536,8 +540,8 @@ inline bool intersects(const Box<T>& b, const Point<T>& p) {
// _____________________________________________________________________________
template <typename T>
inline Point<T> intersection(double p1x, double p1y, double q1x, double q1y, double p2x, double p2y, double q2x,
double q2y) {
inline Point<T> intersection(T p1x, T p1y, T q1x, T q1y, T p2x, T p2y, T q2x,
T q2y) {
/*
* calculates the intersection between two line segments
*/
@ -574,8 +578,8 @@ inline Point<T> intersection(const LineSegment<T>& s1,
// _____________________________________________________________________________
template <typename T>
inline bool lineIntersects(double p1x, double p1y, double q1x, double q1y, double p2x, double p2y, double q2x,
double q2y) {
inline bool lineIntersects(T p1x, T p1y, T q1x, T q1y, T p2x, T p2y, T q2x,
T q2y) {
/*
* checks whether two lines intersect
*/
@ -684,7 +688,6 @@ inline double dist(const Line<T>& la, const Line<T>& lb) {
return d;
}
// _____________________________________________________________________________
inline double innerProd(double x1, double y1, double x2, double y2, double x3,
double y3) {