Azzera filtri
Azzera filtri

How to Determine begin en endpoint of a curve to calculate total curve magnitude?

2 visualizzazioni (ultimi 30 giorni)
Hi,
I want to determine at which sample a curve in the movement of a player was started and at which sample the curve was stopped, to then calculate the magnitude of the total curve.
My input is Mid_Angle(2x11 Matrix), which shows the Index(1) and Value(2) of the MidPoint of the Angle. Furtheron I have the input Ang_Sample(1x1126), which displays the angle between the direction vectors of consecutieve samples.
Right now I have this:
d = 50 --> %number of samples included before and after.
e = 0.4 --> %threshold for curve
for i= 1:length(Mid_Angle)
Ang_Abs = abs(Ang_Sample([Mid_Angle(1,i)-d]:[Mid_Angle(1,i)+d]));
Start_Ang(i) = find(Ang_Abs>e,1,'first')+(Mid_Angle(1,i)-d);
End_Ang(i) = find(Ang_Abs>e,1,'last')+(Mid_Angle(1,i)-d);
Total_Ang(i) = sum(Ang_Sample([Start_Ang(i)]:[End_Ang(i)])); end
I'm not happy with it, because sometimes it doesn't work. I get error ??? Subscript indices must either be real positive integers or logicals, at the first line sometimes. Furtheron, I'm not happy with the way the beginning and End of the curve are deterimined. If after a curve, imideately a new curve is started I get troubles.
What I would like to have is:
1) Determine at which sample before the midpoint of the curve the player started his curve by determining which was the first sample after which all consecutive samples deviated more than 0.4 degrees from the previous. So for example MidAngle Index = 180, and Angle Sample(172:180) are [ 0, 0.5, 0.3, 0.5, 0.8, 1.2, 1.7, 1.6, 1.8] I need a function to tell me that Angle Sample(175) was the first sample at which it started continously deviating for the curve.
2) The same, but now for the endpoint of the curve. So at which sample after the midpoint did de signal stop deviating more than 0.4 per sample?
3) Fill in begin and end of the curve and summate the samples between it to calculate total curve magnitude --> this should be okey.

Risposte (0)

Categorie

Scopri di più su Computational Geometry in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by