{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

Velocity

value public final class Velocity


A two dimensional velocity in pixels per second.

Summary

Nested types

public static class Velocity.Companion

Public methods

final float

The horizontal component of the velocity in pixels per second.

final float

The vertical component of the velocity in pixels per second.

final @NonNull Velocity
copy(float x, float y)

Returns a copy of this Velocity instance optionally overriding the x or y parameter

final @NonNull Velocity
div(float operand)

Division operator.

final float

The horizontal component of the velocity in pixels per second.

final float

The vertical component of the velocity in pixels per second.

final @NonNull Velocity

Binary subtraction operator.

final @NonNull Velocity

Binary addition operator.

final @NonNull Velocity
rem(float operand)

Modulo (remainder) operator.

final @NonNull Velocity
times(float operand)

Multiplication operator.

@NonNull String
final @NonNull Velocity

Unary negation operator.

Public methods

component1

public final float component1()

The horizontal component of the velocity in pixels per second.

component2

public final float component2()

The vertical component of the velocity in pixels per second.

copy

public final @NonNull Velocity copy(float x, float y)

Returns a copy of this Velocity instance optionally overriding the x or y parameter

div

public final @NonNull Velocity div(float operand)

Division operator.

Returns a Velocity whose coordinates are those of the left-hand-side operand (an Velocity) divided by the scalar right-hand-side operand (a Float).

getX

public final float getX()

The horizontal component of the velocity in pixels per second.

getY

public final float getY()

The vertical component of the velocity in pixels per second.

minus

public final @NonNull Velocity minus(@NonNull Velocity other)

Binary subtraction operator.

Returns a Velocity whose x value is the left-hand-side operand's x minus the right-hand-side operand's x and whose y value is the left-hand-side operand's y minus the right-hand-side operand's y.

plus

public final @NonNull Velocity plus(@NonNull Velocity other)

Binary addition operator.

Returns a Velocity whose x value is the sum of the x values of the two operands, and whose y value is the sum of the y values of the two operands.

rem

public final @NonNull Velocity rem(float operand)

Modulo (remainder) operator.

Returns a Velocity whose coordinates are the remainder of dividing the coordinates of the left-hand-side operand (a Velocity) by the scalar right-hand-side operand (a Float).

times

public final @NonNull Velocity times(float operand)

Multiplication operator.

Returns a Velocity whose coordinates are those of the left-hand-side operand (a Velocity) multiplied by the scalar right-hand-side operand (a Float).

toString

public @NonNull String toString()

unaryMinus

public final @NonNull Velocity unaryMinus()

Unary negation operator.

Returns a Velocity with the coordinates negated.

If the Velocity represents an arrow on a plane, this operator returns the same arrow but pointing in the reverse direction.