Remove Lagrange

This commit is contained in:
X9VoiD 2020-12-28 16:54:57 +08:00
parent 7b41edb855
commit dcf093a62e
5 changed files with 0 additions and 153 deletions

View file

@ -1,40 +0,0 @@
using OpenTabletDriver.Plugin.Attributes;
using OpenTabletDriver.Plugin.Tablet.Interpolator;
using OpenTabletDriver.Plugin.Timers;
namespace VoiDPlugins.Filter
{
[PluginName("Lagrange")]
public class Lagrange : Interpolator
{
private readonly LagrangeCore Core = new();
private SyntheticTabletReport Report;
public Lagrange(ITimer timer) : base(timer)
{
}
public override SyntheticTabletReport Interpolate()
{
if (Core.IsFilled)
Report.Position = Core.Predict();
return Report;
}
public override void UpdateState(SyntheticTabletReport report)
{
Report = report;
Core.Add(report.Position);
}
[Property("Samples")]
public int Samples { set => Core.Samples = value; }
[Property("Offset"), Unit("ms")]
public float Offset { get; set; }
[BooleanProperty("Mode 2", "Enable if tablet report is jittery. (most of 266+hz tablets)")]
public bool Jitter { set => Core.Jitter = value; }
}
}

View file

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\.modules\OpenTabletDriver\OpenTabletDriver.Plugin\OpenTabletDriver.Plugin.csproj" />
<ProjectReference Include="..\..\VoiDPlugins.Library\VoiD\VoiD.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net5</TargetFramework>
</PropertyGroup>
</Project>

View file

@ -1,70 +0,0 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using VoiDPlugins.Library;
namespace VoiDPlugins.Filter
{
public class LagrangeCore
{
private RingBuffer<TimeSeriesPoint> Points;
private readonly Stopwatch Watch = new();
private float? prevElapsed;
public int Samples { set => Points = new(value); }
public bool Jitter;
public bool IsFilled { get => Points.IsFilled; }
public float TimeNow { get => (float)Watch.Elapsed.TotalMilliseconds; }
public float ReportInterval = 4;
public LagrangeCore()
{
Watch.Start();
}
~LagrangeCore()
{
Watch.Stop();
}
public void Add(Vector2 point)
{
var now = TimeNow;
Points.Insert(new TimeSeriesPoint(point, now));
if (prevElapsed.HasValue)
{
var interval = now - prevElapsed;
if (interval < ReportInterval * 1.5)
ReportInterval += (float)((interval - ReportInterval) * 0.1);
}
prevElapsed = now;
}
public Vector2 Predict(float offset = 0)
{
Vector2 lagrange = new(0, 0);
var i = 0;
foreach (var z in Points)
{
lagrange += z.Point * Decompose(TimeNow + offset, (float)z.Elapsed, i);
i++;
}
return lagrange;
}
private float Decompose(float interpTime, float time, int decompIndex)
{
float decomposed = 1;
int i = 0;
foreach (var point in Points)
{
if (i != decompIndex)
{
decomposed *= (float)((interpTime - point.Elapsed) / (time - point.Elapsed));
}
i++;
}
return decomposed;
}
}
}

View file

@ -1,16 +0,0 @@
using System.Numerics;
namespace VoiDPlugins.Filter
{
public class TimeSeriesPoint
{
public TimeSeriesPoint(Vector2 point, double elapsed)
{
Point = point;
Elapsed = elapsed;
}
public readonly Vector2 Point;
public double Elapsed;
}
}

View file

@ -31,8 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VoiDPlugins.Library", "VoiD
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VMulti", "VoiDPlugins.Library\VMulti\VMulti.csproj", "{E6A1BA35-D3D4-4F28-9B59-FA946B3039C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lagrange", "Filter\Lagrange\Lagrange.csproj", "{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -154,18 +152,6 @@ Global
{E6A1BA35-D3D4-4F28-9B59-FA946B3039C7}.Release|x64.Build.0 = Release|Any CPU
{E6A1BA35-D3D4-4F28-9B59-FA946B3039C7}.Release|x86.ActiveCfg = Release|Any CPU
{E6A1BA35-D3D4-4F28-9B59-FA946B3039C7}.Release|x86.Build.0 = Release|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Debug|x64.ActiveCfg = Debug|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Debug|x64.Build.0 = Debug|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Debug|x86.ActiveCfg = Debug|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Debug|x86.Build.0 = Debug|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Release|Any CPU.Build.0 = Release|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Release|x64.ActiveCfg = Release|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Release|x64.Build.0 = Release|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Release|x86.ActiveCfg = Release|Any CPU
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{33F0E415-AB65-43F2-8AE2-3462B56B9E91} = {CFC2BC9E-CFD6-4B01-946D-43C26E6C2108}
@ -177,6 +163,5 @@ Global
{D8DBD60E-BE5C-43DE-AEB6-D6ADBAC3BE8C} = {44DF0884-9B34-45CA-92B7-2D57DCA3A1A8}
{DE2D6E1E-F04E-4E0C-BE95-7B8E8AFBCD4C} = {C3E1E369-CD2C-4030-88BE-3D4E7493F8C7}
{E6A1BA35-D3D4-4F28-9B59-FA946B3039C7} = {9B841994-6F85-4834-8C8C-04D196FE388A}
{F1A8C6C3-0189-4D0B-9811-B72B1CBCBCCB} = {6EFE4444-C6E7-4743-8EE5-7A2BE7493457}
EndGlobalSection
EndGlobal