mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
fix: elevation curve x-axis float precision loss
Absolute epoch millis (~1.7e12) exceeds Float precision (ULP ~131s at that magnitude), so 5s-spaced samples collapsed onto identical x coordinates, producing a stepped/jagged curve. Use Long relative time deltas (sample - start) before converting to Float.
This commit is contained in:
1 parent
d7e1ce11c9
commit
4baf3821e5
1 file changed
+4
-4
+4
-4
@@ -104,9 +104,9 @@ fun ElevationCurveChart(
|
||||
|
||||
if (plotWidth <= 0f || plotHeight <= 0f) return@Canvas
|
||||
|
||||
val minTime = startTime.toFloat()
|
||||
val maxTime = endTime.toFloat()
|
||||
val timeRange = maxTime - minTime
|
||||
val minTime = startTime
|
||||
val maxTime = endTime
|
||||
val timeRange = (maxTime - minTime).toFloat()
|
||||
if (timeRange <= 0f) return@Canvas
|
||||
|
||||
// Grid lines
|
||||
@@ -147,7 +147,7 @@ fun ElevationCurveChart(
|
||||
val ptsB = mutableListOf<Offset>()
|
||||
|
||||
for ((time, elev) in samples) {
|
||||
val x = plotLeft + ((time.toFloat() - minTime) / timeRange) * plotWidth
|
||||
val x = plotLeft + ((time - minTime).toFloat() / timeRange) * plotWidth
|
||||
val yA = plotBottom - ((elev.first.toFloat() / maxElev.toFloat()) * plotHeight).coerceIn(0f, plotHeight)
|
||||
val yB = plotBottom - ((elev.second.toFloat() / maxElev.toFloat()) * plotHeight).coerceIn(0f, plotHeight)
|
||||
ptsA.add(Offset(x, yA))
|
||||
|
||||
Reference in new issue
Block a user