-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathDemoData.kt
42 lines (36 loc) · 1.13 KB
/
DemoData.kt
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
/*
* Copyright (c) 2023. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package demoAndTestShared
import org.jetbrains.letsPlot.commons.geometry.DoubleVector
object DemoData {
fun contourDemoData(): Map<String, List<*>> {
val countX = 20
val countY = 20
val mean = DoubleVector(5.0, 5.0)
val height = 1.0
val radius = 10.0
val slop = height / radius
val x = ArrayList<Double>()
val y = ArrayList<Double>()
val z = ArrayList<Double>()
for (row in 0 until countY) {
for (col in 0 until countX) {
val dist = DoubleVector(col.toDouble(), row.toDouble()).subtract(mean).length()
val v = if (dist >= radius)
0.0
else
height - dist * slop
x.add(col.toDouble())
y.add(row.toDouble())
z.add(v)
}
}
val map = HashMap<String, List<*>>()
map["x"] = x
map["y"] = y
map["z"] = z
return map
}
}