Skip to content

Commit

Permalink
Improve plate solver for similar stars
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Dec 21, 2024
1 parent 33b40a6 commit 0897fad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id("com.vanniktech.maven.publish") version "0.30.0"
}

val versionName = "10.1.1"
val versionName = "10.1.2"

mavenPublishing {
coordinates("com.kylecorry", "sol", versionName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.kylecorry.sol.science.astronomy.stars

import com.kylecorry.sol.math.analysis.Trigonometry
import com.kylecorry.sol.math.sumOfFloat
import com.kylecorry.sol.science.astronomy.Astronomy
import com.kylecorry.sol.time.Time
import com.kylecorry.sol.units.Coordinate
Expand Down Expand Up @@ -36,7 +35,7 @@ internal class PlateSolver(
while (queue.isNotEmpty()) {
val reading = queue.removeAt(0)
val possibleMatches = catalogQuads.sortedBy {
reading.second.zip(it.second.second).sumOfFloat { (a, b) ->
reading.second.zip(it.second.second).maxOf { (a, b) ->
(a - b).absoluteValue
}
}.take(6)
Expand All @@ -45,7 +44,7 @@ internal class PlateSolver(
var minDistanceMatch: Pair<Star, Pair<AltitudeAzimuth, FloatArray>>? = null
for (possibleMatch in possibleMatches) {
val distance =
reading.second.zip(possibleMatch.second.second).sumOfFloat { (a, b) ->
reading.second.zip(possibleMatch.second.second).maxOf { (a, b) ->
(a - b).absoluteValue
}
if (matches.none { it.second == possibleMatch.first } || distance < matches.first { it.second == possibleMatch.first }.third) {
Expand All @@ -70,7 +69,7 @@ internal class PlateSolver(
Triple(
reading.first,
minDistanceMatch.first,
reading.second.zip(minDistanceMatch.second.second).sumOfFloat { (a, b) ->
reading.second.zip(minDistanceMatch.second.second).maxOf { (a, b) ->
(a - b).absoluteValue
})
)
Expand Down Expand Up @@ -112,7 +111,8 @@ internal class PlateSolver(
currentSeparation += degreesStep
}

return quads.distinct()
// Remove duplicates (based on the start and distance array)
return quads.distinctBy { it.first to it.second.second.toList() }.toList()
}

private fun getQuads(
Expand Down Expand Up @@ -164,7 +164,7 @@ internal class PlateSolver(
val maxDistance = distances.maxOrNull() ?: 0f

// Normalize the distances
val normalizedDistances = distances.map { it / maxDistance }.sorted().toFloatArray()
val normalizedDistances = distances.map { it / maxDistance }.toFloatArray()

quads.add(Pair(reading, normalizedDistances))
}
Expand Down

0 comments on commit 0897fad

Please sign in to comment.