From 033bc2d48af9de8f157129a943fc0fe41b3366a7 Mon Sep 17 00:00:00 2001 From: bartjuhhh <bart.knuiman@wur.nl> Date: Wed, 20 Sep 2023 16:30:16 +0200 Subject: [PATCH] Improved catmullrom. Reduced max move speed. --- README.md | 14 ++++++++++++++ README.md.backup | 14 ++++++++++++++ ZeroMQTest/Code/ActiveOV.cs | 2 +- ZeroMQTest/Code/Network.cs | 15 ++++----------- sample.gif | 3 +++ sample0.gif | 3 +++ 6 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 README.md create mode 100644 README.md.backup create mode 100644 sample.gif create mode 100644 sample0.gif diff --git a/README.md b/README.md new file mode 100644 index 0000000..9281ea1 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +## 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. + + + diff --git a/README.md.backup b/README.md.backup new file mode 100644 index 0000000..622ebea --- /dev/null +++ b/README.md.backup @@ -0,0 +1,14 @@ +## 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. + + + diff --git a/ZeroMQTest/Code/ActiveOV.cs b/ZeroMQTest/Code/ActiveOV.cs index 3751372..a80162a 100644 --- a/ZeroMQTest/Code/ActiveOV.cs +++ b/ZeroMQTest/Code/ActiveOV.cs @@ -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; } } } diff --git a/ZeroMQTest/Code/Network.cs b/ZeroMQTest/Code/Network.cs index 2d17bce..eca0e7a 100644 --- a/ZeroMQTest/Code/Network.cs +++ b/ZeroMQTest/Code/Network.cs @@ -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 ) diff --git a/sample.gif b/sample.gif new file mode 100644 index 0000000..58f00c5 --- /dev/null +++ b/sample.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9698b20a6d50929a02601f23ed89ef4ded8fd52bd5cf8a82b2a325aa0028deaf +size 15834259 diff --git a/sample0.gif b/sample0.gif new file mode 100644 index 0000000..1243c46 --- /dev/null +++ b/sample0.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4431d72ddfa4cc768624a780965ff4c33b5b3aafa2f01ffd1ec3aeea12fb976c +size 27630316 -- GitLab