Commit 4fcca4f6 authored by VAN TOLL Wouter's avatar VAN TOLL Wouter
Browse files

Replaced two "distance" calls by their squared version.

parent 6edb1f16
......@@ -294,7 +294,7 @@ float CostFunction::ComputeTimeToCollision_LineSegment(const Vector2D& position,
float CostFunction::ComputeTimeToCollision_LineSegmentInterior(const Vector2D& position, const Vector2D& velocity, const float radius, const LineSegment2D& lineSegment) const
{
// Check if the disk is already colliding with the line segment right now
if (distanceToLine(position, lineSegment.first, lineSegment.second, true) <= radius)
if (distanceToLineSquared(position, lineSegment.first, lineSegment.second, true) <= radius*radius)
return 0;
// Compute the intersection of the disk's future trajectory and the line segment, ignoring the disk's radius for now (we will correct this later)
......
......@@ -64,7 +64,7 @@ std::vector<const Agent*> WorldBase::computeNeighboringAgents_Flat(const Vector2
std::vector<LineSegment2D> WorldBase::computeNeighboringObstacles_Flat(const Vector2D& position, float search_radius) const
{
// TODO: implement more efficient neighbor search for obstacles
const float radiusSquared = search_radius * search_radius;
std::vector<LineSegment2D> result;
// loop over all obstacle edges
......@@ -73,7 +73,7 @@ std::vector<LineSegment2D> WorldBase::computeNeighboringObstacles_Flat(const Vec
for (const auto& edge : obs.GetEdges())
{
// if this line segment is clsoe enough, add it to the result
if (distanceToLine(position, edge.first, edge.second, true) <= search_radius)
if (distanceToLineSquared(position, edge.first, edge.second, true) <= radiusSquared)
result.push_back(edge);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment