summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClementTsang <cjhtsang@uwaterloo.ca>2020-01-31 21:01:33 -0500
committerClementTsang <cjhtsang@uwaterloo.ca>2020-01-31 21:01:33 -0500
commit67ff2f28eb1c60f022f64305bb25e2971fb1e716 (patch)
tree4368cbb3f35c73df2caf20a34fe8db7aa6c62693 /src
parent971384cf3a0b30c1e3456a508fb475c6ef606f5a (diff)
Tweaked point generation a bit again
Diffstat (limited to 'src')
-rw-r--r--src/app/data_farmer.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/app/data_farmer.rs b/src/app/data_farmer.rs
index 02b725cc..f370aefc 100644
--- a/src/app/data_farmer.rs
+++ b/src/app/data_farmer.rs
@@ -264,13 +264,18 @@ pub fn generate_joining_points(
let mut points: Vec<(TimeOffset, Value)> = Vec::new();
// Convert time floats first:
- let time_difference = (*end_x).duration_since(*start_x).as_millis() as f64;
+ let tmp_time_diff = (*end_x).duration_since(*start_x).as_millis() as f64;
+ let time_difference = if tmp_time_diff == 0.0 {
+ 0.001
+ } else {
+ tmp_time_diff
+ };
let value_difference = end_y - start_y;
// Let's generate... about this many points!
let num_points = std::cmp::min(
std::cmp::max(
- (value_difference.abs() / (time_difference + 0.0001) * 500.0) as u64,
+ (value_difference.abs() / time_difference * 500.0) as u64,
100,
),
500,