]> rtime.felk.cvut.cz Git - hubacji1/psp.git/commitdiff
Move collide functions to `bcar` lib
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 1 Aug 2019 13:30:37 +0000 (15:30 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 1 Aug 2019 13:31:54 +0000 (15:31 +0200)
CHANGELOG.md
api/psp.h
src/psp.cc
ut/psp.t.cc

index 279b5b6af677154dd188f472f260830a37848bd7..df50b821edaeacfb327b1a27c0a420b59978479c 100644 (file)
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog][] and this project adheres to
 [Semantic Versioning]: http://semver.org/
 
 ## Unreleased
+### Deleted
+- Collide functions `intersection` and `inside`. Moved to `bcar` library.
 
 ## 0.1.0 - 2019-07-25
 ### Added
index b054c420cf65728f5419b96e094aec62e83df3b4..752811fd97aa03b9690adda54f5de937b692faa1 100644 (file)
--- a/api/psp.h
+++ b/api/psp.h
@@ -74,41 +74,4 @@ class PSPlanner {
                 PSPlanner();
 };
 
-/*! \brief Return intersection of two line segments.
-
-The output is tuple `std::tuple<bool, double, double>`, where the first
-value is true when there is an intersection and false otherwise. The
-second and third parameters in the return tuple are coordinates of the
-intersection.
-
-\see https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
-
-\param x1 First line segment first `x` coordinate.
-\param y1 First line segment first `y` coordinate.
-\param x2 First line segment second `x` coordinate.
-\param y2 First line segment second `y` coordinate.
-\param x3 Second line segment first `x` coordinate.
-\param y3 Second line segment first `y` coordinate.
-\param x4 Second line segment second `x` coordinate.
-\param y4 Second line segment second `y` coordinate.
-*/
-std::tuple<bool, double, double> intersect(
-        double x1, double y1,
-        double x2, double y2,
-        double x3, double y3,
-        double x4, double y4
-);
-
-/*! \brief Is `x, y` coordinate in polynom `poly`?
-
-Return `true` if `x, y` coordinate is inside of polynom `poly`.
-
-\see https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule
-
-\param x Horizontal coordinate.
-\param y Vertical coordinate.
-\param poly The vector of coordinates.
-*/
-bool inside(double x, double y, std::vector<std::tuple<double, double>> poly);
-
 #endif /* PSP_H */
index 9e53e36ec1d7c54cde0c8565cf3067c1f72245c8..66f7f810add831a3f46474fd1079a6280ab2efbf 100644 (file)
@@ -376,44 +376,3 @@ bool PSPlanner::forward()
 PSPlanner::PSPlanner()
 {
 }
-
-std::tuple<bool, double, double> intersect(
-        double x1, double y1,
-        double x2, double y2,
-        double x3, double y3,
-        double x4, double y4
-)
-{
-        double deno = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
-        if (deno == 0)
-                return std::make_tuple(false, 0, 0);
-        double t = (x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4);
-        t /= deno;
-        double u = (x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3);
-        u *= -1;
-        u /= deno;
-        if (t < 0 || t > 1 || u < 0 || u > 1)
-                return std::make_tuple(false, 0, 0);
-        return std::make_tuple(true, x1 + t * (x2 - x1), y1 + t * (y2 - y1));
-}
-
-bool inside(double x, double y, std::vector<std::tuple<double, double>> poly)
-{
-        unsigned int i = 0;
-        unsigned int j = 3;
-        bool inside = false;
-        for (i = 0; i < 4; i++) {
-                if (
-                        (std::get<1>(poly[i]) > y) != (std::get<1>(poly[j]) > y)
-                        && (
-                                x < std::get<0>(poly[i])
-                                + (std::get<0>(poly[j]) - std::get<0>(poly[i]))
-                                * (y - std::get<1>(poly[i]))
-                                / (std::get<1>(poly[j]) - std::get<1>(poly[i]))
-                        )
-                )
-                        inside = !inside;
-                j = i;
-        }
-        return inside;
-}
index 1e6fcccc8459a109ed9c8e3d6f52ff17b12d25cc..36195b6235e40c07c1a92cf2df5bbe147ec1ee11 100644 (file)
@@ -36,12 +36,6 @@ WVTEST_MAIN("parallel parking slot planner")
         WVPASS(inside(psp.gc().rfx(), psp.gc().rfy(), slot));
 
         // init collide
-        auto tmpi1 = intersect(1, 1, 3, 3, 1, 3, 3, 1);
-        WVPASS(std::get<0>(tmpi1));
-        WVPASSEQ_DOUBLE(std::get<1>(tmpi1), 2, 0.00001);
-        WVPASSEQ_DOUBLE(std::get<2>(tmpi1), 2, 0.00001);
-        auto tmpi2 = intersect(1, 1, 1, 3, 3, 1, 3, 3);
-        WVPASS(!std::get<0>(tmpi2));
         PSPlanner tpsp;
         tpsp.ps().border(2, 3, 4, 3, 4, 8, 2, 8);
         tpsp.gc() = BicycleCar(psp.gc());