unit

fun unit(x: Double, y: Double): Vec2(source)

Creates a unit vector from a given x and y coordinate.

Return

A unit vector with the same direction as the coordinates.

Parameters

x

The x-coordinate of the vector.

y

The y-coordinate of the vector.

Throws

if both x and y are zero.