You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/kotlin/com/kylecorry/sol/math/interpolation/Interpolation.kt
+5-19Lines changed: 5 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
packagecom.kylecorry.sol.math.interpolation
2
2
3
3
importcom.kylecorry.sol.math.Vector2
4
+
importcom.kylecorry.sol.shared.Executor
5
+
importcom.kylecorry.sol.shared.SequentialExecutor
4
6
importkotlin.math.ceil
5
7
importkotlin.math.floor
6
8
@@ -135,36 +137,20 @@ object Interpolation {
135
137
* Interpolates the isoline for a grid of values using the Marching Squares algorithm.
136
138
* @param grid A 2D grid of point to value pairs. The points should be equidistant. It is recommended to supply 1 extra row and column on each side of the grid to ensure the isoline extends to the edges.
137
139
* @param threshold The value to use as the isoline threshold.
140
+
* @param executor The executor of the isoline calculations to optionally process in parallel. Defaults to sequential processing.
138
141
* @param interpolator A function that takes a percentage (0 to 1) and two values (percent from a to b), and returns the interpolated point.
139
142
* @return A list of isoline segments.
140
143
*/
141
144
fun <T> getIsoline(
142
145
grid:List<List<Pair<T, Float>>>,
143
146
threshold:Float,
147
+
executor:Executor = SequentialExecutor(),
144
148
interpolator: (percent: Float, a: T, b: T) ->T
145
149
): List<IsolineSegment<T>> {
146
150
returnMarchingSquares.getIsoline(
147
151
grid,
148
152
threshold,
149
-
interpolator
150
-
)
151
-
}
152
-
153
-
/**
154
-
* Interpolates the isoline for a grid of values using the Marching Squares algorithm. This function returns the calculators so it can be calculated in parallel.
155
-
* @param grid A 2D grid of point to value pairs. The points should be equidistant. It is recommended to supply 1 extra row and column on each side of the grid to ensure the isoline extends to the edges.
156
-
* @param threshold The value to use as the isoline threshold.
157
-
* @param interpolator A function that takes a percentage (0 to 1) and two values (percent from a to b), and returns the interpolated point.
0 commit comments