MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / CSV2

Class CSV2

src/main/java/trace/mocap/CSV2.kt:11–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9import java.util.*
10
11class CSV2(val directory: String, val suffix: String) {
12
13 var points = mutableListOf<TCB3>()
14
15 init {
16
17 val vv = File(directory).listFiles { dir, n -> n.endsWith(suffix) }
18
19 if (vv == null) throw IllegalArgumentException("can't list '$directory'")
20 if (vv.size == 0) throw IllegalArgumentException("'$directory' has no matching files")
21
22 Arrays.sort(vv)
23
24 val numPoints = Files.readAllLines(vv[0].toPath())
25
26 (0 until numPoints.size).forEach { points.add(TCB3()) }
27
28 for (i in 0 until vv.size) {
29 val reader = BufferedReader(FileReader(vv[i]))
30
31 var index = 0
32 while (reader.ready()) {
33 val l = reader.readLine()
34
35 val pieces = l.split(",")
36
37 points[index].newNode(i.toDouble(), Vec3(pieces[0].toDouble(), pieces[1].toDouble(), pieces[2].toDouble()))
38 index++
39 }
40
41 }
42
43 (0 until numPoints.size).forEach { points[it].tcbAll() }
44
45 }
46
47
48 fun atTime(time: Double): List<Vec3> {
49 return points.map { it.evaluate(time * it.duration(), Vec3()) }
50 }
51
52 fun duration(): Double {
53 return points[0].duration()
54 }
55
56
57}

Callers

nothing calls this directly

Calls 9

FileFunction · 0.85
TCB3Class · 0.85
newNodeMethod · 0.80
tcbAllMethod · 0.80
Vec3Class · 0.50
forEachMethod · 0.45
addMethod · 0.45
readLineMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected