object Velocity extends Serializable
This companion object of class Velocity
exists primarily to provide convenience
methods for creating new instances of Velocity
.
The object has an alias in the top-level package o1, so it’s accessible to students
simply via import o1._
.
- Alphabetic
- By Inheritance
- Velocity
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- val Still: Velocity
a zero-speed Velocity with a direction of
NoDirection
- def apply(vector: Pos): Velocity
Returns a Velocity whose
dx
anddy
equal thex
andy
of the given Pos, respectively. - def apply(dx: Double, dy: Double): Velocity
Returns a Velocity with the given
dx
anddy
. - def average(velocities: Seq[Velocity]): Velocity
Returns the average of all the given velocities.
Returns the average of all the given velocities. If the given collection is empty, returns Velocity.Still.
- def between(from: Pos, to: Pos): Velocity
Returns a Velocity from two given Pos objects: the direction is determined from the first given Pos towards and the speed equals the distance between the two
Pos
es. - def sum(velocities: Seq[Velocity]): Velocity
Returns the sum of all the given velocities.
Returns the sum of all the given velocities. If the given collection is empty, returns Velocity.Still.