Arc direction as computed property
This commit is contained in:
parent
86fce7ec68
commit
429eefa3f7
@ -35,13 +35,16 @@ public data class Arc(
|
|||||||
LEFT, RIGHT
|
LEFT, RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
override val length: Double get() {
|
override val length: Double
|
||||||
val angle: Double = theta(if (direction == Direction.LEFT) start.theta - end.theta else end.theta - start.theta)
|
get() {
|
||||||
|
val angle: Double =
|
||||||
|
theta(if (direction == Direction.LEFT) start.theta - end.theta else end.theta - start.theta)
|
||||||
val proportion = angle / (2 * PI)
|
val proportion = angle / (2 * PI)
|
||||||
return circle.circumference * proportion
|
return circle.circumference * proportion
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val direction: Direction = if (start.y < circle.center.y) {
|
internal val direction: Direction
|
||||||
|
get() = if (start.y < circle.center.y) {
|
||||||
if (start.theta > PI) Direction.RIGHT else Direction.LEFT
|
if (start.theta > PI) Direction.RIGHT else Direction.LEFT
|
||||||
} else if (start.y > circle.center.y) {
|
} else if (start.y > circle.center.y) {
|
||||||
if (start.theta < PI) Direction.RIGHT else Direction.LEFT
|
if (start.theta < PI) Direction.RIGHT else Direction.LEFT
|
||||||
|
Loading…
Reference in New Issue
Block a user