# Vec

Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/Vec.kt+class:androidx.ink.geometry.Vec) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***


```
public abstract class Vec
```

<br />

Known direct subclasses [ImmutableVec](https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec), [MutableVec](https://developer.android.com/reference/androidx/ink/geometry/MutableVec)

|---|---|
| `https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` | An immutable two-dimensional vector, i.e. an (x, y) coordinate pair. |
| `https://developer.android.com/reference/androidx/ink/geometry/MutableVec` | A mutable two-dimensional vector, i.e. an (x, y) coordinate pair. |

*** ** * ** ***

A two-dimensional vector, i.e. an (x, y) coordinate pair. It can be used to represent either:

1. A two-dimensional offset, i.e. the difference between two points

2. A point in space, i.e. treating the vector as an offset from the origin

## Summary

| ### Public fields |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#ORIGIN()` The origin of the coordinate system, i.e. (0, 0). |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 180.0) float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#absoluteAngleBetweenInDegrees(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec rhs)` Returns the absolute angle between the given vectors. |
| `static final void` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec rhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec output)` Adds the x and y values of both `https://developer.android.com/reference/androidx/ink/geometry/Vec` objects and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`. |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = -180.0, to = 180.0) @https://developer.android.com/reference/androidx/ink/geometry/AngleDegreesFloat float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeDirectionDegrees()()` The angle between the positive x-axis and this vec, in the direction of the positive y-axis. |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeMagnitude()()` The length of the `https://developer.android.com/reference/androidx/ink/geometry/Vec`. |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeMagnitudeSquared()()` The squared length of the `https://developer.android.com/reference/androidx/ink/geometry/Vec`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeNegation()()` Returns a newly allocated vector with the same magnitude, but pointing in the opposite direction. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeNegation(androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVec)` Modifies `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeNegation(androidx.ink.geometry.MutableVec)`, which may be `this`, into a vector with the same magnitude, but pointing in the opposite direction. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeOrthogonal()()` Returns a newly allocated vector with the same magnitude as this one, but rotated by (positive) 90 degrees. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeOrthogonal(androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVec)` Modifies `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeOrthogonal(androidx.ink.geometry.MutableVec)`, which may be `this`, into a vector with the same magnitude as this one, but rotated by (positive) 90 degrees. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeUnitVec()()` Returns a newly allocated vector with the same direction as this one, but with a magnitude of `1`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeUnitVec(androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVec)` Modifies `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeUnitVec(androidx.ink.geometry.MutableVec)`, which may be `this`, into a vector with the same direction as this one, but with a magnitude of `1`. |
| `static final float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#determinant(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec rhs)` Returns the determinant (×) of the two vectors. |
| `static final void` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, float rhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec output)` Divides the x and y values of the `https://developer.android.com/reference/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`. |
| `static final float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#dotProduct(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec rhs)` Returns the dot product (⋅) of the two vectors. |
| `abstract float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#getX()()` The `https://developer.android.com/reference/androidx/ink/geometry/Vec`'s offset in the x-direction |
| `abstract float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#getY()()` The `https://developer.android.com/reference/androidx/ink/geometry/Vec`'s offset in the y-direction |
| `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec other, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float tolerance)` Compares this `https://developer.android.com/reference/androidx/ink/geometry/Vec` with `https://developer.android.com/reference/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)`, and returns true if the difference between `https://developer.android.com/reference/androidx/ink/geometry/Vec#x()` from `this` and `https://developer.android.com/reference/androidx/ink/geometry/Vec#x()` from `https://developer.android.com/reference/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)` is less than `https://developer.android.com/reference/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)`, and likewise for `https://developer.android.com/reference/androidx/ink/geometry/Vec#y()`. |
| `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec other, @https://developer.android.com/reference/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float toleranceDegrees )` Returns true if the angle formed by `this` and `https://developer.android.com/reference/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)` is within `https://developer.android.com/reference/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)` of 0 degrees or 180 degrees. |
| `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec other, @https://developer.android.com/reference/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float toleranceDegrees )` Returns true if the angle formed by `this` and `https://developer.android.com/reference/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)` is within `https://developer.android.com/reference/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)` of ±90 degrees. |
| `static final void` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)(float lhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec rhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec output)` Multiplies the x and y values of the `https://developer.android.com/reference/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`. |
| `static final void` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, float rhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec output)` Multiplies the x and y values of the `https://developer.android.com/reference/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`. |
| `static final @https://developer.android.com/reference/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/androidx/annotation/FloatRange(from = -180.0, to = 180.0, fromInclusive = false) float` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#signedAngleBetweenInDegrees(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec rhs)` Returns the signed angle between the given vectors. |
| `static final void` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec lhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec rhs, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec output)` Subtracts the x and y values of `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` from the x and y values of `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Vec#toImmutable()()` Returns an immutable copy of this object. |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/ink/geometry/AndroidGraphicsConverter.https://developer.android.com/reference/androidx/ink/geometry/Vec#(androidx.ink.geometry.Vec).populatePointF(android.graphics.PointF)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html out )` Writes the values from this `https://developer.android.com/reference/androidx/ink/geometry/Vec` to `https://developer.android.com/reference/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Vec).populatePointF(android.graphics.PointF)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/ink/geometry/AndroidGraphicsConverter.https://developer.android.com/reference/androidx/ink/geometry/Vec#(androidx.ink.geometry.Vec).toPointF()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec receiver)` Constructs a `https://developer.android.com/reference/android/graphics/PointF.html` with the same coordinates as the `https://developer.android.com/reference/androidx/ink/geometry/Vec` |

## Public fields

### ORIGIN

```
public static final @NonNull ImmutableVec ORIGIN
```

The origin of the coordinate system, i.e. (0, 0).

## Public methods

### absoluteAngleBetweenInDegrees

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final @AngleDegreesFloat @FloatRange(from = 0.0, to = 180.0) float absoluteAngleBetweenInDegrees(@NonNull Vec lhs, @NonNull Vec rhs)
```

Returns the absolute angle between the given vectors. The return value will lie in the interval 0, 180.0.

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final void add(@NonNull Vec lhs, @NonNull Vec rhs, @NonNull MutableVec output)
```

Adds the x and y values of both `https://developer.android.com/reference/androidx/ink/geometry/Vec` objects and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`.

### computeDirectionDegrees

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @FloatRange(from = -180.0, to = 180.0) @AngleDegreesFloat float computeDirectionDegrees()
```

The angle between the positive x-axis and this vec, in the direction of the positive y-axis. If either component of the vector is NaN, this returns NaN. Otherwise, the returned value will lie in the interval -180, 180, and will have the same sign as the vector's y-component.

Following the behavior of `atan2`, this will return either ±0 or ±180 for the zero vector, depending on the signs of the zeros.

### computeMagnitude

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @FloatRange(from = 0.0) float computeMagnitude()
```

The length of the `https://developer.android.com/reference/androidx/ink/geometry/Vec`.

### computeMagnitudeSquared

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @FloatRange(from = 0.0) float computeMagnitudeSquared()
```

The squared length of the `https://developer.android.com/reference/androidx/ink/geometry/Vec`.

### computeNegation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull ImmutableVec computeNegation()
```

Returns a newly allocated vector with the same magnitude, but pointing in the opposite direction. For performance-sensitive code, use `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeNegation()` with a pre-allocated instance of `https://developer.android.com/reference/androidx/ink/geometry/MutableVec`.

### computeNegation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull MutableVec computeNegation(@NonNull MutableVec outVec)
```

Modifies `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeNegation(androidx.ink.geometry.MutableVec)`, which may be `this`, into a vector with the same magnitude, but pointing in the opposite direction. Returns `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeNegation(androidx.ink.geometry.MutableVec)`.

### computeOrthogonal

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull ImmutableVec computeOrthogonal()
```

Returns a newly allocated vector with the same magnitude as this one, but rotated by (positive) 90 degrees. For performance-sensitive code, use `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeOrthogonal()` with a pre-allocated instance of `https://developer.android.com/reference/androidx/ink/geometry/MutableVec`.

### computeOrthogonal

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull MutableVec computeOrthogonal(@NonNull MutableVec outVec)
```

Modifies `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeOrthogonal(androidx.ink.geometry.MutableVec)`, which may be `this`, into a vector with the same magnitude as this one, but rotated by (positive) 90 degrees. Returns `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeOrthogonal(androidx.ink.geometry.MutableVec)`.

### computeUnitVec

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull ImmutableVec computeUnitVec()
```

Returns a newly allocated vector with the same direction as this one, but with a magnitude of `1`. This is equivalent to (but faster than) calling `https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec#fromDirectionInDegreesAndMagnitude(kotlin.Float,kotlin.Float)` with `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeDirectionDegrees()` and `1`.

In keeping with the above equivalence, this will return \<±1, ±0\> for the zero vector, depending on the signs of the zeros.

For performance-sensitive code, use `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeUnitVec()` with a pre-allocated instance of `https://developer.android.com/reference/androidx/ink/geometry/MutableVec`.

### computeUnitVec

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull MutableVec computeUnitVec(@NonNull MutableVec outVec)
```

Modifies `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeUnitVec(androidx.ink.geometry.MutableVec)`, which may be `this`, into a vector with the same direction as this one, but with a magnitude of `1`. Returns `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeUnitVec(androidx.ink.geometry.MutableVec)`. This is equivalent to (but faster than) calling `https://developer.android.com/reference/androidx/ink/geometry/MutableVec#populateFromDirectionInDegreesAndMagnitude(kotlin.Float,kotlin.Float)` with `https://developer.android.com/reference/androidx/ink/geometry/Vec#computeDirectionDegrees()` and `1`.

In keeping with the above equivalence, this will return \<±1, ±0\> for the zero vector, depending on the signs of the zeros.

### determinant

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final float determinant(@NonNull Vec lhs, @NonNull Vec rhs)
```

Returns the determinant (×) of the two vectors. The determinant can be thought of as the z-component of the 3D cross product of the two vectors, if they were placed on the xy-plane in 3D space. The determinant has the property that, for vectors a and b: a × b = ‖a‖ \* ‖b‖ \* sin(θ) where ‖d‖ is the magnitude of the vector, and θ is the signed angle from a to b.

### divide

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final void divide(@NonNull Vec lhs, float rhs, @NonNull MutableVec output)
```

Divides the x and y values of the `https://developer.android.com/reference/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`.

### dotProduct

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final float dotProduct(@NonNull Vec lhs, @NonNull Vec rhs)
```

Returns the dot product (⋅) of the two vectors. The dot product has the property that, for vectors a and b: a ⋅ b = ‖a‖ \* ‖b‖ \* cos(θ) where ‖d‖ is the magnitude of the vector, and θ is the angle from a to b.

### getX

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public abstract float getX()
```

The `https://developer.android.com/reference/androidx/ink/geometry/Vec`'s offset in the x-direction

### getY

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public abstract float getY()
```

The `https://developer.android.com/reference/androidx/ink/geometry/Vec`'s offset in the y-direction

### isAlmostEqual

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final boolean isAlmostEqual(@NonNull Vec other, @FloatRange(from = 0.0) float tolerance)
```

Compares this `https://developer.android.com/reference/androidx/ink/geometry/Vec` with `https://developer.android.com/reference/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)`, and returns true if the difference between `https://developer.android.com/reference/androidx/ink/geometry/Vec#x()` from `this` and `https://developer.android.com/reference/androidx/ink/geometry/Vec#x()` from `https://developer.android.com/reference/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)` is less than `https://developer.android.com/reference/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)`, and likewise for `https://developer.android.com/reference/androidx/ink/geometry/Vec#y()`.

### isParallelTo

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final boolean isParallelTo(
    @NonNull Vec other,
    @AngleDegreesFloat @FloatRange(from = 0.0) float toleranceDegrees
)
```

Returns true if the angle formed by `this` and `https://developer.android.com/reference/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)` is within `https://developer.android.com/reference/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)` of 0 degrees or 180 degrees.

### isPerpendicularTo

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final boolean isPerpendicularTo(
    @NonNull Vec other,
    @AngleDegreesFloat @FloatRange(from = 0.0) float toleranceDegrees
)
```

Returns true if the angle formed by `this` and `https://developer.android.com/reference/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)` is within `https://developer.android.com/reference/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)` of ±90 degrees.

### multiply

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final void multiply(float lhs, @NonNull Vec rhs, @NonNull MutableVec output)
```

Multiplies the x and y values of the `https://developer.android.com/reference/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`.

### multiply

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final void multiply(@NonNull Vec lhs, float rhs, @NonNull MutableVec output)
```

Multiplies the x and y values of the `https://developer.android.com/reference/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`.

### signedAngleBetweenInDegrees

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final @AngleDegreesFloat @FloatRange(from = -180.0, to = 180.0, fromInclusive = false) float signedAngleBetweenInDegrees(@NonNull Vec lhs, @NonNull Vec rhs)
```

Returns the signed angle between the given vectors. The return value will lie in the interval (-180.0, 180.0\]. A positive result indicates the angle between the first vector and the second is in the direction from the positive x-axis towards the positive y-axis.

### subtract

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final void subtract(@NonNull Vec lhs, @NonNull Vec rhs, @NonNull MutableVec output)
```

Subtracts the x and y values of `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` from the x and y values of `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` and stores the result in `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`.

### toImmutable

Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
public abstract @NonNull ImmutableVec toImmutable()
```

Returns an immutable copy of this object. This will return itself if called on an immutable instance.

## Extension functions

### AndroidGraphicsConverter.populatePointF

Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/AndroidGraphicsConversionExtensions.android.kt+function:populatePointF)

```
public final @NonNull PointF AndroidGraphicsConverter.populatePointF(
    @NonNull Vec receiver,
    @NonNull PointF out
)
```

Writes the values from this `https://developer.android.com/reference/androidx/ink/geometry/Vec` to `https://developer.android.com/reference/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Vec).populatePointF(android.graphics.PointF)`.

Returns the modified `https://developer.android.com/reference/android/graphics/PointF.html` instance to allow chaining calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Vec).populatePointF(android.graphics.PointF)` |

### AndroidGraphicsConverter.toPointF

Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/AndroidGraphicsConversionExtensions.android.kt+function:toPointF)

```
public final @NonNull PointF AndroidGraphicsConverter.toPointF(@NonNull Vec receiver)
```

Constructs a `https://developer.android.com/reference/android/graphics/PointF.html` with the same coordinates as the `https://developer.android.com/reference/androidx/ink/geometry/Vec`