Skip to content

Commit

Permalink
Hopefully fix unreal max speeds
Browse files Browse the repository at this point in the history
  • Loading branch information
kilpkonn committed Jul 30, 2020
1 parent ffe7e79 commit 830a0b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/ee/taltech/iti0213/sportsapp/track/Track.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ class Track {
if (pauses.isEmpty() || pauses.last() != track?.size) {
movingTime += location.elapsedTimestamp - currentTimeElapsed

val distanceFromLast = TrackLocation.calcDistanceBetween(location, lastLocation ?: location)
val bearingFromLast = TrackLocation.calcBearingBetween(lastLocation ?: location, location) / 180.0f * PI
val moveVector = speedFilter.process(
val distanceFromLast = 3.6 * 1_000_000_000 * TrackLocation.calcDistanceBetween(location, lastLocation!!)
val bearingFromLast = TrackLocation.calcBearingBetween(lastLocation!!, location) * PI / 180.0f
val speedVector = speedFilter.process(
Vector2D(
distanceFromLast * sin(bearingFromLast),
distanceFromLast * cos(bearingFromLast)
distanceFromLast * sin(bearingFromLast) / (location.elapsedTimestamp - currentTimeElapsed),
distanceFromLast * cos(bearingFromLast) / (location.elapsedTimestamp - currentTimeElapsed)
)
)

val currSpeed = 3.6 * 1_000_000_000 * moveVector.length() / (location.elapsedTimestamp - currentTimeElapsed)
val currSpeed = speedVector.length()
if (currSpeed > maxSpeed) {
maxSpeed = currSpeed
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 830a0b8

Please sign in to comment.