1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Structure that specifies maximum allowable magnitudes for distances,
/// durations, and velocity differences to be considered equal.
class Tolerance {
/// Creates a [Tolerance] object. By default, the distance, time, and velocity
/// tolerances are all ±0.001; the constructor arguments override this.
///
/// The arguments should all be positive values.
const Tolerance({
this.distance: _kEpsilonDefault,
this.time: _kEpsilonDefault,
this.velocity: _kEpsilonDefault
});
static const double _kEpsilonDefault = 1e-3;
/// A default tolerance of 0.001 for all three values.
static const Tolerance defaultTolerance = const Tolerance();
/// The magnitude of the maximum distance between two points for them to be
/// considered within tolerance.
///
/// The units for the distance tolerance must be the same as the units used
/// for the distances that are to be compared to this tolerance.
final double distance;
/// The magnitude of the maximum duration between two times for them to be
/// considered within tolerance.
///
/// The units for the time tolerance must be the same as the units used
/// for the times that are to be compared to this tolerance.
final double time;
/// The magnitude of the maximum difference between two velocities for them to
/// be considered within tolerance.
///
/// The units for the velocity tolerance must be the same as the units used
/// for the velocities that are to be compared to this tolerance.
final double velocity;
@override
String toString() => 'Tolerance(distance: ±$distance, time: ±$time, velocity: ±$velocity)';
}