Skip to content

Commit

Permalink
Merge pull request #87 from UmbrellaLeaf5/hill_common_tangents
Browse files Browse the repository at this point in the history
Hill common tangents
  • Loading branch information
UmbrellaLeaf5 authored May 15, 2024
2 parents ef2020a + 4572b96 commit bfb9466
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
22 changes: 0 additions & 22 deletions math/optimal_way/obstacles.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ class CircleObstacle {

double GetRadius() const { return radius_; }

std::vector<LinearFunction> GetTangentLines() { return tangents_; }

std::vector<Point> GetTangentPoints() { return tangent_points_; }

void AddTangentLine(const LinearFunction& tangent) {
tangents_.push_back(tangent);
}

void AddTangentPoint(const Point& tangent_point) {
tangent_points_.push_back(tangent_point);
}
Expand All @@ -98,9 +92,6 @@ class CircleObstacle {

double radius_;

// Касательные
std::vector<LinearFunction> tangents_;

// Точки касания
std::vector<Point> tangent_points_;
};
Expand All @@ -127,18 +118,8 @@ class PolygonObstacle {

std::vector<Point> GetVertexes() const { return vertexes_; }

std::vector<LinearFunction> GetTangentLines() { return tangents_; }

std::vector<Point> GetTangentPoints() { return tangent_points_; }

void DeleteTangentPoint(std::size_t index) {
tangent_points_.erase(tangent_points_.begin() + index);
}

void AddTangentLine(const LinearFunction& tangent) {
tangents_.push_back(tangent);
}

void AddTangentPoint(const Point& tangent_point) {
tangent_points_.push_back(tangent_point);
}
Expand All @@ -158,9 +139,6 @@ class PolygonObstacle {
// Вершины
std::vector<Point> vertexes_;

// Касательные
std::vector<LinearFunction> tangents_;

// Точки касания
std::vector<Point> tangent_points_;
};
Expand Down
16 changes: 7 additions & 9 deletions math/optimal_way/optimal_way.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ void OptimalWayCalculator::AddTangent(const LinearFunction& tangent,
std::make_shared<Point>(tangent_points.second);
tangent_points.second.another_tangent_point =
std::make_shared<Point>(tangent_points.first);
obstacle1.AddTangentLine(tangent);
obstacle1.AddTangentPoint(tangent_points.first);
obstacle2.AddTangentLine(tangent);
obstacle2.AddTangentPoint(tangent_points.second);
}

Expand Down Expand Up @@ -139,13 +137,13 @@ void OptimalWayCalculator::AddGraphTangentPoints() {
DistanceBetweenPoints(
graph_.nodes[graph_.nodes.size() - vertexes.size()]->point,
new_node->point));

for (std::size_t j = 0; j < graph_.nodes.size(); ++j) {
if ((graph_.nodes[j]->point.another_tangent_point) &&
(new_node->point == *graph_.nodes[j]->point.another_tangent_point))
graph_.AddEdge(
graph_.nodes[j]->number, new_node->number,
DistanceBetweenPoints(graph_.nodes[j]->point, new_node->point));
for (auto& tangent_point : poly.GetTangentPoints()) {
if (tangent_point != new_node->point) continue;
for (auto& node : graph_.nodes) {
if (*tangent_point.another_tangent_point != node->point) continue;
graph_.AddEdge(node->number, new_node->number,
DistanceBetweenPoints(node->point, new_node->point));
}
}
}
}
Expand Down

0 comments on commit bfb9466

Please sign in to comment.