lasers: try to change the quantization sampling step as little as possible

This commit is contained in:
Andrei Alexeyev 2024-05-06 03:07:29 +02:00
parent c8b017f974
commit 92183e7655
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -155,10 +155,10 @@ static bool laser_prepare_sampling_params(Laser *l, float step, LaserSamplingPar
return false;
}
float ns = ceilf(c / step);
float ns = ceilf((c + step) / step);
out_params->num_samples = ns;
out_params->time_shift = t;
out_params->time_step = c / (ns - 1);
out_params->time_step = (c + step) / ns;
return true;
}
@ -248,7 +248,9 @@ static int quantize_laser(Laser *l) {
top_left.as_cmplx = a;
bottom_right.as_cmplx = a;
for(uint i = 1; i < sp.num_samples; ++i, t += sp.time_step) {
float maxtime = sp.time_shift + l->timespan;
for(uint i = 1; i < sp.num_samples; ++i, t = min(t + sp.time_step, maxtime)) {
b = laser_pos_at(l, t);
if(i < sp.num_samples - 1 && (t - t0) < thres_temporal) {