Skip to content

Commit 35b43ac

Browse files
committed
feat: enhance KineticState with factory methods for position, velocity, and acceleration
1 parent 0be77be commit 35b43ac

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/main/kotlin/dev/nextftc/control/KineticState.kt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ package dev.nextftc.control
2121
/**
2222
* Holds a state of a kinetic system.
2323
*
24-
* @param position the state's position
25-
* @param velocity the state's velocity
26-
* @param acceleration the state's acceleration
24+
* @property position the state's position
25+
* @property velocity the state's velocity
26+
* @property acceleration the state's acceleration
2727
*
2828
* @author BeepBot99, Zach Harel
2929
*/
@@ -59,6 +59,24 @@ data class KineticState @JvmOverloads constructor(
5959
operator fun unaryMinus(): KineticState = KineticState(-position, -velocity, -acceleration)
6060

6161
companion object {
62+
/**
63+
* A kinetic state with all components set to zero.
64+
*/
6265
@JvmField val ZERO = KineticState()
66+
67+
/**
68+
* Creates a kinetic state with the given position and zero velocity and acceleration.
69+
*/
70+
@JvmStatic fun pos(position: Double) = KineticState(position=position)
71+
72+
/**
73+
* Creates a kinetic state with the given velocity and zero position and acceleration.
74+
*/
75+
@JvmStatic fun vel(velocity: Double) = KineticState(velocity=velocity)
76+
77+
/**
78+
* Creates a kinetic state with the given acceleration and zero position and velocity.
79+
*/
80+
@JvmStatic fun accel(acceleration: Double) = KineticState(acceleration=acceleration)
6381
}
6482
}

0 commit comments

Comments
 (0)