This commit is contained in:
Emma Broman
2020-03-06 11:01:43 -05:00
committed by Emma Broman
parent 3bda1d961d
commit 7aecf87d5b
4 changed files with 8 additions and 43 deletions

View File

@@ -30,8 +30,6 @@
#include <openspace/scene/scene.h>
#include <openspace/query/query.h>
#include <ghoul/logging/logmanager.h>
#include <glm/gtx/intersect.hpp>
#include <glm/gtx/perpendicular.hpp>
#include <glm/gtx/projection.hpp>
#include <algorithm>
#include <vector>
@@ -215,18 +213,17 @@ glm::dvec3 AvoidCollisionCurve::roundedSpline(double t, const glm::dvec3 &a,
// find velocities at b and c
glm::dvec3 cb = c - b;
glm::dvec3 bc = -cb;
if (!isNormalizable(cb)) {
return b;
}
glm::dvec3 ab = a - b;
// a and b are the same point. try finding a substitue
// a and b are the same point
if (!isNormalizable(ab)) {
ab = b - c;
if (!isNormalizable(ab)) {
ab = glm::dvec3(0.0, 1.0, 0.0);
}
ab = bc;
}
glm::dvec3 bVelocity = glm::normalize(cb) - glm::normalize(ab);
@@ -234,15 +231,12 @@ glm::dvec3 AvoidCollisionCurve::roundedSpline(double t, const glm::dvec3 &a,
glm::normalize(bVelocity) : glm::dvec3(0.0, 1.0, 0.0);
glm::dvec3 dc = d - c;
// d and c are the same point. try finding a substitue
// d and c are the same point
if (!isNormalizable(dc)) {
dc = c - b;
if (!isNormalizable(dc)) {
dc = glm::dvec3(0.0, 1.0, 0.0);
}
dc = cb;
}
glm::dvec3 bc = (-1.0)*cb;
glm::dvec3 cVelocity = glm::normalize(dc) - glm::normalize(bc);
cVelocity = isNormalizable(cVelocity) ?
glm::normalize(cVelocity) : glm::dvec3(0.0, 1.0, 0.0);
@@ -250,7 +244,7 @@ glm::dvec3 AvoidCollisionCurve::roundedSpline(double t, const glm::dvec3 &a,
double cbDistance = glm::length(cb);
double tangetLength = cbDistance;
// Distances in space can be extremely large, so we dont want to let the tangents have the complete length.
// Distances in space can be extremely large, so we dont want the tangents to always have the full length.
const double tangentlengthThreshold = 1E10; // TODO: What's a good threshold?? ALSO make global
if (tangetLength > tangentlengthThreshold)
tangetLength = tangentlengthThreshold;

View File

@@ -109,27 +109,6 @@ namespace openspace::autonavigation::interpolation {
return cp1 * (1.0 - t) + cp2 * t;
}
glm::dvec3 catmullRom(double t, const glm::dvec3 &p0, const glm::dvec3 &p1,
const glm::dvec3 &p2, const glm::dvec3 &p3)
{
ghoul_assert(t >= 0 && t <= 1.0, "Interpolation variable out of range [0, 1]");
if (t <= 0.0) return p1;
if (t >= 1.0) return p2;
const double t2 = t * t;
const double t3 = t2 * t;
glm::dvec3 result = (
p0 * (-0.5 * t3 + t2 - 0.5 * t) +
p1 * ( 1.5 * t3 - 2.5 * t2 + 1.0) +
p2 * (-1.5 * t3 + 2.0 * t2 + 0.5 * t) +
p3 * ( 0.5 * t3 - 0.5 * t2)
);
return result;
}
glm::dvec3 hermite(double t, const glm::dvec3 &p1, const glm::dvec3 &p2,
const glm::dvec3 &tangent1, const glm::dvec3 &tangent2)
{

View File

@@ -55,9 +55,6 @@ namespace openspace::autonavigation::interpolation {
glm::dvec3 linear(double t, const glm::dvec3 &cp1, const glm::dvec3 &cp2);
glm::dvec3 catmullRom(double t, const glm::dvec3 &a, const glm::dvec3 &b,
const glm::dvec3 &c, const glm::dvec3 &d);
glm::dvec3 hermite(double t, const glm::dvec3 &cp1, const glm::dvec3 &cp2,
const glm::dvec3 &tangent1, const glm::dvec3 &tangent2);

View File

@@ -25,13 +25,8 @@
#include <modules/autonavigation/pathcurves.h>
#include <modules/autonavigation/helperfunctions.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
#include <openspace/query/query.h>
#include <ghoul/logging/logmanager.h>
#include <glm/gtx/intersect.hpp>
#include <glm/gtx/perpendicular.hpp>
#include <glm/gtx/projection.hpp>
#include <algorithm>
#include <vector>