O1Library Docs
Fall 2026
Docs API

# Velocity

o1.world.Velocity
See the Velocity companion class
object Velocity

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.*`.

## Attributes

Companion
  class
Graph
Supertypes
  trait Product
  trait Mirror
  class Object
  trait Matchable
  class Any
Self type
  Velocity.type

## Members list

### Type members

#### Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

## Attributes

Inherited from:
  Mirror

type MirroredLabel <: String

The name of the type.

The name of the type.

## Attributes

Inherited from:
  Mirror

### Value members

#### Concrete methods

def apply(dx: Double, dy: Double): Velocity

Creates a `Velocity` with the given `dx` and `dy`.

Creates a `Velocity` with the given `dx` and `dy`.

## Attributes

def apply(vector: Pos): Velocity

Creates a `Velocity` whose `dx` and `dy` equal the `x` and `y` of the given Pos, respectively.

Creates a `Velocity` whose `dx` and `dy` equal the `x` and `y` of the given Pos, respectively.

## Attributes

def average(velocities: Seq[Velocity]): Velocity

Returns the average of all the given velocities. If the given collection is empty, returns Velocity.Still.

Returns the average of all the given velocities. If the given collection is empty, returns Velocity.Still.

## Attributes

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.

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.

## Attributes

def sum(velocities: Seq[Velocity]): Velocity

Returns the sum of all the given velocities. If the given collection is empty, returns Velocity.Still.

Returns the sum of all the given velocities. If the given collection is empty, returns Velocity.Still.

## Attributes

#### Concrete fields

val Still: Velocity

a zero-speed Velocity with a direction of `NoDirection`

a zero-speed Velocity with a direction of `NoDirection`

## Attributes

### Givens

given derived$CanEqual: CanEqual[Velocity, Velocity]