Precise drawing after grouping max/min points?

For general discussion related FlowStone
Post Reply
Nowhk
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Precise drawing after grouping max/min points?

Post by Nowhk »

I'm about to draw somethings like 882 points inside a window of (horizontally) 200 pixel. As tulamide suggested to me time ago, it's worthless to draw each point, since I'll max draw 200 of them. So I'll group block of them (882/5=177 points) using min/max points to draw it (Mem to Float Array Min/Max prim):

Immagine.png
Immagine.png (32.25 KiB) Viewed 11602 times

precise drawing.fsm
(13.22 KiB) Downloaded 1586 times

as you can see in this "analysis" (you can switch between original points and grouped version), blu points are the original, reds the min and yellow the max, for each group.
Now, what I need to do is to "join" those points, getting the same signal and keeping (that's the important aspect) min/max value for each peak. My idea is:

- start from index t=0.
- When the next max is increasing, use current max point (yellow one)
- When the next max is decreasing, use current min point (red one)

it seems to works very well (you can see the white line is taking the points it should take). But this don't always works. In fact at the 4° change of slope, this is not true. It should take in order red-red-red-yellow-yellow. But with my method, its red-red-red-red-yellow (because between the 3° and 4° yellow there is a decreasing):

Immagine2.png
Immagine2.png (3.02 KiB) Viewed 11602 times

so, a defect in the curve.
How would you fix it? I mean: how would you choose points (after resampling with min/max) that exactly hover original signal? (i.e. the meaning of this "grouping points" task)?

Hope you can help me! Thanks dudes!
Post Reply