KinematicState

org.abh80.nf.core.math.KinematicState
See theKinematicState companion object
case class KinematicState(position: Vector3D, velocity: Vector3D, acceleration: Vector3D) extends TimeShiftable[KinematicState]

Represents the state of an object in terms of its kinematic properties (in space-time): position, velocity, and acceleration. Provides methods to calculate its state after a time shift, as well as methods to compute derived values such as position and velocity shifts. All vectors are in SI units (meters for position, meters/second for velocity, meters/second² for acceleration).

Instances of this class are immutable and time-shiftable, adhering to the TimeShiftable trait.

Value parameters

acceleration

The acceleration vector of the object in 3D space (meters/second²).

position

The position vector of the object in 3D space (meters).

velocity

The velocity vector of the object in 3D space (meters/second).

Attributes

See also

TimeShiftable

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Constructors

def this(position: Vector3D)

Auxiliary constructor for creating a KinematicState with the specified position. Sets velocity and acceleration to zero by default.

Auxiliary constructor for creating a KinematicState with the specified position. Sets velocity and acceleration to zero by default.

Value parameters

position

The initial position vector of the kinematic state (meters).

Attributes

def this(position: Vector3D, velocity: Vector3D)

Auxiliary constructor for creating a KinematicState with the specified position and velocity. Sets acceleration to zero by default.

Auxiliary constructor for creating a KinematicState with the specified position and velocity. Sets acceleration to zero by default.

Value parameters

position

The initial position vector of the kinematic state (meters).

velocity

The initial velocity vector of the kinematic state (meters/second).

Attributes

Concrete methods

def *(scalar: Double): KinematicState
Implicitly added by BinOp

Scales the kinematic state by a scalar value. Each component (position, velocity, acceleration) is multiplied by the scalar.

Scales the kinematic state by a scalar value. Each component (position, velocity, acceleration) is multiplied by the scalar.

Value parameters

scalar

The scaling factor.

Attributes

Returns

A new KinematicState with scaled components.

override def ++(dt: Double): KinematicState

Shifts the kinematic state forward by a time interval dt using constant-acceleration kinematics. Returns a new KinematicState with updated position and velocity, while acceleration remains unchanged.

Shifts the kinematic state forward by a time interval dt using constant-acceleration kinematics. Returns a new KinematicState with updated position and velocity, while acceleration remains unchanged.

Value parameters

dt

Time interval in seconds.

Attributes

Returns

A new KinematicState representing the state after time dt.

Definition Classes
Implicitly added by BinOp

Subtracts another kinematic state from this one. Performs component-wise subtraction: position - position, velocity - velocity, acceleration - acceleration.

Subtracts another kinematic state from this one. Performs component-wise subtraction: position - position, velocity - velocity, acceleration - acceleration.

Value parameters

second

The kinematic state to subtract.

Attributes

Returns

A new KinematicState representing the difference.

Implicitly added by BinOp

Computes the cross product of two kinematic states. The cross product is applied component-wise, with velocity and acceleration terms derived to maintain consistency:

Computes the cross product of two kinematic states. The cross product is applied component-wise, with velocity and acceleration terms derived to maintain consistency:

  • Position: P₁ × P₂
  • Velocity: (V₁ × P₂) + (P₁ × V₂)
  • Acceleration: (A₁ × P₂) + (P₁ × A₂) + 2(V₁ × V₂)

where P₁, V₁, A₁ are the position, velocity, and acceleration of the first state, and P₂, V₂, A₂ are those of the second state.

Value parameters

second

The kinematic state to compute the cross product with.

Attributes

Returns

A new KinematicState representing the cross product.

Computes the angular momentum of the object based on its position and velocity.

Computes the angular momentum of the object based on its position and velocity.

The angular momentum L is calculated as: L = r × v where:

  • r is the position vector (meters)
  • v is the velocity vector (meters/second)

The resulting vector is perpendicular to both the position and velocity vectors, with magnitude equal to |r|·|v|·sin(θ), where θ is the angle between r and v.

Attributes

Returns

A Vector3D representing the angular momentum vector.

Note

This is the momentum for a unit mass. Multiply this result by the object's mass to get the actual momentum.

Computes the angular velocity of the object based on its position and velocity.

Computes the angular velocity of the object based on its position and velocity.

The angular velocity ω is calculated as: ω = (r × v) / |r|² where:

  • r is the position vector (meters)
  • v is the velocity vector (meters/second)
  • |r|² is the squared magnitude of the position vector

If the position vector is zero (|r| = 0), the angular velocity is undefined, and a zero vector is returned to avoid division by zero.

Attributes

Returns

A Vector3D representing the angular velocity in radians per second.

Returns a new KinematicState with all components negated. Negation applies to position, velocity, and acceleration vectors.

Returns a new KinematicState with all components negated. Negation applies to position, velocity, and acceleration vectors.

Attributes

Returns

A new KinematicState with negated position, velocity, and acceleration.

Normalizes the position vector and adjusts velocity and acceleration to maintain consistent derivatives.

Normalizes the position vector and adjusts velocity and acceleration to maintain consistent derivatives.

The position is normalized to unit length: u = r / |r|, where r is the position vector. The velocity is computed as the derivative of the normalized position: u̇ = v - (u · v)·u, where v is the original velocity. The acceleration is computed as the derivative of u̇: ü = w - 2(u · v)·v + (3(u · v)² - v · v - u · w)·u, where w is the original acceleration.

Attributes

Returns

A new KinematicState with normalized position and consistent velocity and acceleration derivatives.

def positionShiftedBy(dt: Double): Vector3D

Calculates the position after a time interval dt using the kinematic equation: r(t + dt) = r(t) + v(t)·dt + (1/2)·a(t)·dt²

Calculates the position after a time interval dt using the kinematic equation: r(t + dt) = r(t) + v(t)·dt + (1/2)·a(t)·dt²

where:

  • r(t) is the initial position (meters)
  • v(t) is the initial velocity (meters/second)
  • a(t) is the acceleration (meters/second²)
  • dt is the time interval (seconds)

Value parameters

dt

Time interval in seconds.

Attributes

Returns

New position vector after time dt (meters).

override def toString: String

Returns a string representation of the kinematic state. Format: {Pos[position], Vel[velocity], Acc[acceleration]}.

Returns a string representation of the kinematic state. Format: {Pos[position], Vel[velocity], Acc[acceleration]}.

Attributes

Returns

A string describing the position, velocity, and acceleration vectors.

Definition Classes
Any
def velocityShiftedBy(dt: Double): Vector3D

Calculates the velocity after a time interval dt using the kinematic equation: v(t + dt) = v(t) + a(t)·dt

Calculates the velocity after a time interval dt using the kinematic equation: v(t + dt) = v(t) + a(t)·dt

where:

  • v(t) is the initial velocity (meters/second)
  • a(t) is the acceleration (meters/second²)
  • dt is the time interval (seconds)

Value parameters

dt

Time interval in seconds.

Attributes

Returns

New velocity vector after time dt (meters/second).

Inherited methods

def ++(timeFormat: TimeFormat): KinematicState

Get a timeshifted instance of T

Get a timeshifted instance of T

Value parameters

timeFormat

time to be shifted in TimeFormat

Attributes

See also

TimeFormat

Inherited from:
TimeShiftable
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
def shiftBy(timeFormat: TimeFormat): KinematicState

Get a timeshifted instance of T

Get a timeshifted instance of T

Value parameters

timeFormat

time to be shifted in TimeFormat

Attributes

See also

TimeFormat

Inherited from:
TimeShiftable
def shiftBy(dt: Double): KinematicState

Get a timeshifted instance of T

Get a timeshifted instance of T

Value parameters

dt

time to be shifted in seconds

Attributes

Inherited from:
TimeShiftable