moved

fun Point.moved(length: Double, angle: Double): Point

Return

An instance of Point moved by the length and angle.

val a = pointOf(xN, yN)
val dX = xM - xN
val dY = yM - yN
val length = kotlin.math.sqrt(dX * dX + dY * dY)
val angle = kotlin.math.PI / 4
val b = a.updated(length = length, angle = angle)
assertEquals(b.x, a.x + dX)
assertEquals(b.y, a.y + dY)

Y
| b
yM - *
| /
| /
| a/ (kotlin.math.PI / 4)
yN - * - - - - - - - -
|
+---|---------|-----> X
xN xM

Author

Stanley Wintergreen

Since

0.1.0

Sources

Link copied to clipboard