Skip to content
Snippets Groups Projects
Commit 033bc2d4 authored by Knuiman, Bart's avatar Knuiman, Bart
Browse files

Improved catmullrom. Reduced max move speed.

parent 08f74af3
No related branches found
No related tags found
No related merge requests found
## OVAPI Broker
Queries live OV-info from NDOVLoket and bundles the data to provide methods for usage in applications.
## Dependencies
- None
### Usage:
1. Start the .exe after build.
2. Optionally put it in a web server (ISS 8) using docker.
![](./sample0.gif)
## OVAPI Broker
Queries live OV-info from NDOVLoket and bundles the data to provide methods for usage in applications.
## Dependencies
- None
### Usage:
1. Start the .exe after build.
2. Optionally put it in a web server (ISS 8) using docker.
![](./sample.gif)
......@@ -175,7 +175,7 @@ namespace WanderOV
}
if (vehicle.speedMtrPerSec < 5) vehicle.speedMtrPerSec = 5;
if (vehicle.speedMtrPerSec > 20) vehicle.speedMtrPerSec = 20;
if (vehicle.speedMtrPerSec > 15) vehicle.speedMtrPerSec = 15;
}
}
}
......
......@@ -197,7 +197,7 @@ namespace OVAPI.Code
p2 = route.Point( nextPointIdx ).point;
(var splinePnt, var splineTangent) = CatmullRom( t, p0, p1, p2, p3 );
pntCatMull = splinePnt;
interpolant = (endPoint, movedDistance+advanceDistance, Vector2.Normalize( splineTangent ));
interpolant = (endPoint, movedDistance+advanceDistance, splineTangent );
Debug.Assert( MathF.Abs( interpolant.dir.Length()-1 ) < 0.001f );
return true;
}
......@@ -205,15 +205,8 @@ namespace OVAPI.Code
// From: bard.google.com
static (Vector2 position, Vector2 tangent) CatmullRom( float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3 )
{
// Check T in range.
if (t <= 0.0f)
{
t = 0.01f;
}
else if (t >= 1.0f)
{
t = 0.99f;
}
if (t<00) t=0.01f;
if (t>=1) t=0.99f;
// Calc spline coefficients.
float t2 = t * t;
......@@ -229,7 +222,7 @@ namespace OVAPI.Code
// Calc tangent.
var tangent = 3 * (m1 * (p2 - p0) + m2 * (p3 - p1)) - (m0 * (p1 - p0) + m3 * (p3 - p2));
return (position, tangent);
return (position, Vector2.Normalize( tangent ) );
}
static int GetPointInSegment( Vector2 p, Vector2 v0, Vector2 v1, out Vector2 interpolated )
......
sample.gif 0 → 100644 LFS
Image diff could not be displayed: it is too large. Options to address this: view the blob.
sample0.gif 0 → 100644 LFS
Image diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment