45 public SampleType
this[
int idx] {
46 get {
return _buffer[idx].value; }
51 public void Add(SampleType sample,
float sampleTime) {
60 public SampleType
Get(
int idx) {
68 public void Set(
int idx, SampleType sample,
float sampleTime) {
72 public void SetLatest(SampleType sample,
float sampleTime) {
73 if (
Count == 0)
Set(0, sample, sampleTime);
74 else Set(
Count - 1, sample, sampleTime);
90 public abstract DerivativeType
Delta();
92 #region foreach Support
121 if (
Count <= 1) {
return Vector3.zero; }
123 Vector3 deltaPerTimeSum = Vector3.zero;
124 for (
int i = 0; i <
Count - 1; i++) {
127 return deltaPerTimeSum / (
Count - 1);
149 if (
Count <= 1) {
return 0f; }
151 float deltaPerTimeSum = 0f;
152 for (
int i = 0; i <
Count - 1; i++) {
155 return deltaPerTimeSum / (
Count - 1);
177 if (
Count <= 1)
return Vector3.zero;
179 var deltaSum = Vector3.zero;
180 for (
int i = 0; i <
Count - 1; i++) {
182 var sample1 =
_buffer.Get(i + 1);
183 var r0 = sample0.value;
184 var t0 = sample0.time;
185 var r1 = sample1.value;
186 var t1 = sample1.time;
188 var delta = (r1.From(r0)).ToAngleAxisVector();
189 var deltaTime = t1.From(t0);
191 deltaSum += delta / deltaTime;
194 return deltaSum / (
Count - 1);
Allows you to add to a capped-size ring buffer of Ts and, when full, compute the buffer's average cha...
DeltaBuffer(int bufferSize)
void Add(SampleType sample, float sampleTime)
override Vector3 Delta()
Returns the average change between each sample per unit time, or zero if the buffer contains one or f...
RingBuffer< ValueTimePair > _buffer
abstract DerivativeType Delta()
Returns the average change between each sample per unit time.
void SetLatest(SampleType sample, float sampleTime)
IndexableEnumerator< SampleType > GetEnumerator()
void Set(int idx, SampleType sample, float sampleTime)
A ring buffer of floats with a Delta() function that computes the buffer's average change over time....
DeltaFloatBuffer(int bufferSize)
override float Delta()
Returns the average change between each sample per unit time, or zero if the buffer is empty.
A ring buffer of Quaternions with a Delta() function that computes the buffer's average change over t...
override Vector3 Delta()
Returns the average angular velocity of Quaternions in the buffer as an angle-axis vector,...
DeltaQuaternionBuffer(int bufferSize)
This easy-to-implement interface represents the ability to index into a collection of elements of typ...