File: LineAndBearing.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (42 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download | duplicates (4)
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
package tim.prune.function.comparesegments;

import tim.prune.data.Bearing;
import tim.prune.data.DataPoint;

/** Holds the information about a single line between two (not necessarily consecutive) track points and its bearing */
public class LineAndBearing
{
	final PointData _fromPoint;
	final PointData _toPoint;
	final double _bearing;
	final double _distToFromPointRadians;
	final double _distAlongRadians;

	LineAndBearing(PointData fromPoint, PointData toPoint)
	{
		_fromPoint = fromPoint;
		_toPoint = toPoint;
		_bearing = Bearing.calculateDegrees(_fromPoint._point, toPoint._point);
		_distToFromPointRadians = fromPoint._distanceToHereRadians;
		_distAlongRadians = toPoint._distanceToHereRadians - fromPoint._distanceToHereRadians;
	}

	DataPoint getFromPoint() {
		return _fromPoint._point;
	}

	DataPoint getToPoint() {
		return _toPoint._point;
	}

	long getMilliseconds() {
		return getToPoint().getTimestamp().getMillisecondsSince(getFromPoint().getTimestamp());
	}

	double getInterpolatedSpeed(double inFraction)
	{
		final double fromSpeed = _fromPoint._speedRadiansPerSec;
		final double toSpeed = _toPoint._speedRadiansPerSec;
		return fromSpeed + inFraction * (toSpeed - fromSpeed);
	}
}