forked from kscience/kmath
Merge remote-tracking branch 'space/artdegt' into artdegt
This commit is contained in:
commit
93bc15f346
@ -255,7 +255,6 @@ private fun constructTangentCircles(point: DoubleVector2D,
|
|||||||
val center1 = point + normalVectors(direction, r).first
|
val center1 = point + normalVectors(direction, r).first
|
||||||
val center2 = point + normalVectors(direction, r).second
|
val center2 = point + normalVectors(direction, r).second
|
||||||
val p1 = center1 - point
|
val p1 = center1 - point
|
||||||
val p2 = center2 - point
|
|
||||||
return if (atan2(p1.y, p1.x) - atan2(direction.y, direction.x) in listOf(PI/2, -3*PI/2)) {
|
return if (atan2(p1.y, p1.x) - atan2(direction.y, direction.x) in listOf(PI/2, -3*PI/2)) {
|
||||||
mapOf(DubinsPath.SimpleType.L to Circle2D(center1, r),
|
mapOf(DubinsPath.SimpleType.L to Circle2D(center1, r),
|
||||||
DubinsPath.SimpleType.R to Circle2D(center2, r))
|
DubinsPath.SimpleType.R to Circle2D(center2, r))
|
||||||
|
@ -7,7 +7,10 @@ package space.kscience.kmath.trajectory
|
|||||||
|
|
||||||
import space.kscience.kmath.geometry.Circle2D
|
import space.kscience.kmath.geometry.Circle2D
|
||||||
import space.kscience.kmath.geometry.Euclidean2DSpace.vector
|
import space.kscience.kmath.geometry.Euclidean2DSpace.vector
|
||||||
|
import space.kscience.kmath.geometry.equalsFloat
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class DubinsTest {
|
class DubinsTest {
|
||||||
@Test
|
@Test
|
||||||
@ -31,7 +34,7 @@ class DubinsTest {
|
|||||||
finalRadius,
|
finalRadius,
|
||||||
obstacles)
|
obstacles)
|
||||||
val length = pathLength(shortestPath(outputTangents))
|
val length = pathLength(shortestPath(outputTangents))
|
||||||
println(length)
|
assertEquals(length, 27.2113183, 1e-6)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -65,19 +68,7 @@ class DubinsTest {
|
|||||||
finalRadius,
|
finalRadius,
|
||||||
obstacles)
|
obstacles)
|
||||||
val length = pathLength(shortestPath(paths))
|
val length = pathLength(shortestPath(paths))
|
||||||
println(length)
|
assertEquals(length,28.9678224, 1e-6)
|
||||||
for (path in paths) {
|
|
||||||
println(pathLength(path))
|
|
||||||
println(path.size)
|
|
||||||
for (tangent in path) {
|
|
||||||
// println(tangent.route)
|
|
||||||
// println(tangent.startCircle)
|
|
||||||
// println(tangent.endCircle)
|
|
||||||
// println(Euclidean2DSpace.norm(tangent.lineSegment.end - tangent.lineSegment.begin))
|
|
||||||
}
|
|
||||||
println()
|
|
||||||
println()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
fun equalCircles() {
|
fun equalCircles() {
|
||||||
|
@ -12,6 +12,7 @@ import space.kscience.kmath.geometry.LineSegment
|
|||||||
import space.kscience.kmath.geometry.equalsLine
|
import space.kscience.kmath.geometry.equalsLine
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertFailsWith
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class TangentTest {
|
class TangentTest {
|
||||||
@ -60,18 +61,4 @@ class TangentTest {
|
|||||||
val c2 = Circle2D(vector(0.0, 0.0), 1.0)
|
val c2 = Circle2D(vector(0.0, 0.0), 1.0)
|
||||||
assertEquals(emptyMap(), c1.tangentsToCircle(c2))
|
assertEquals(emptyMap(), c1.tangentsToCircle(c2))
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// fun nonExistingTangents() {
|
|
||||||
// assertFailsWith<NotImplementedError> {
|
|
||||||
// val c1 = Circle2D(vector(0.0, 0.0), 1.0)
|
|
||||||
// val c2 = Circle2D(vector(2.0, 0.0), 1.0)
|
|
||||||
// c1.tangentsToCircle(c2)
|
|
||||||
// }
|
|
||||||
// assertFailsWith<NotImplementedError> {
|
|
||||||
// val c1 = Circle2D(vector(0.0, 0.0), 1.0)
|
|
||||||
// val c2 = Circle2D(vector(0.5, 0.0), 1.0)
|
|
||||||
// c1.tangentsToCircle(c2)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user