# 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)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

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

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | An immutable two-dimensional vector, i.e. an (x, y) coordinate pair. |
| `https://developer.android.com/reference/kotlin/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 companion functions |
|---|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 180.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#absoluteAngleBetweenInDegrees(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Returns the absolute angle between the given vectors. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, output: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Adds the x and y values of both `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` objects and stores the result in `https://developer.android.com/reference/kotlin/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/kotlin/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#determinant(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Returns the determinant (×) of the two vectors. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, output: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Divides the x and y values of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#divide(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#dotProduct(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Returns the dot product (⋅) of the two vectors. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)(lhs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, rhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, output: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Multiplies the x and y values of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#multiply(kotlin.Float,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, output: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Multiplies the x and y values of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` by the Float and stores the result in `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`, which may be `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#multiply(androidx.ink.geometry.Vec,kotlin.Float,androidx.ink.geometry.MutableVec)`. | Cmn |
| `@https://developer.android.com/reference/kotlin/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = -180.0, to = 180.0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#signedAngleBetweenInDegrees(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Returns the signed angle between the given vectors. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)(lhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, rhs: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, output: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Subtracts the x and y values of `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/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/kotlin/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`. | Cmn |

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#ORIGIN()` The origin of the coordinate system, i.e. (0, 0). | Cmn |

| ### Public functions |
|---|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = -180.0, to = 180.0) @https://developer.android.com/reference/kotlin/androidx/ink/geometry/AngleDegreesFloat https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeDirectionDegrees()()` The angle between the positive x-axis and this vec, in the direction of the positive y-axis. | Cmn |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeMagnitude()()` The length of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec`. | Cmn |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeMagnitudeSquared()()` The squared length of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeNegation()()` Returns a newly allocated vector with the same magnitude, but pointing in the opposite direction. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeNegation(androidx.ink.geometry.MutableVec)(outVec: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Modifies `https://developer.android.com/reference/kotlin/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. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeOrthogonal()()` Returns a newly allocated vector with the same magnitude as this one, but rotated by (positive) 90 degrees. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeOrthogonal(androidx.ink.geometry.MutableVec)(outVec: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Modifies `https://developer.android.com/reference/kotlin/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. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeUnitVec()()` Returns a newly allocated vector with the same direction as this one, but with a magnitude of `1`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#computeUnitVec(androidx.ink.geometry.MutableVec)(outVec: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Modifies `https://developer.android.com/reference/kotlin/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`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)(other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, tolerance: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Compares this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` with `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)`, and returns true if the difference between `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#x()` from `this` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#x()` from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)` is less than `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isAlmostEqual(androidx.ink.geometry.Vec,kotlin.Float)`, and likewise for `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#y()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)( other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, toleranceDegrees: @https://developer.android.com/reference/kotlin/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns true if the angle formed by `this` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)` is within `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isParallelTo(androidx.ink.geometry.Vec,kotlin.Float)` of 0 degrees or 180 degrees. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)( other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec, toleranceDegrees: @https://developer.android.com/reference/kotlin/androidx/ink/geometry/AngleDegreesFloat @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns true if the angle formed by `this` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)` is within `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#isPerpendicularTo(androidx.ink.geometry.Vec,kotlin.Float)` of ±90 degrees. | Cmn |
| `abstract https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#toImmutable()()` Returns an immutable copy of this object. | Cmn |

| ### Public properties |
|---|---|---|
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#x()` The `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec`'s offset in the x-direction | Cmn |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#y()` The `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec`'s offset in the y-direction | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#(androidx.ink.geometry.Vec).populatePointF(android.graphics.PointF)(out: https://developer.android.com/reference/android/graphics/PointF.html)` Writes the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` to `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Vec).populatePointF(android.graphics.PointF)`. | android |
| `https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#(androidx.ink.geometry.Vec).toPointF()()` Constructs a `https://developer.android.com/reference/android/graphics/PointF.html` with the same coordinates as the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec#(androidx.ink.geometry.Vec).toOffset()()` Returns an `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` with the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec`. | android |

## Public companion functions

### absoluteAngleBetweenInDegrees

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

```
fun absoluteAngleBetweenInDegrees(lhs: Vec, rhs: Vec): @AngleDegreesFloat @FloatRange(from = 0.0, to = 180.0) Float
```

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

### add

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

```
fun add(lhs: Vec, rhs: Vec, output: MutableVec): Unit
```

Adds the x and y values of both `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` objects and stores the result in `https://developer.android.com/reference/kotlin/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/kotlin/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#add(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`.

### determinant

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

```
fun determinant(lhs: Vec, rhs: Vec): Float
```

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

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

```
fun divide(lhs: Vec, rhs: Float, output: MutableVec): Unit
```

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

### dotProduct

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

```
fun dotProduct(lhs: Vec, rhs: Vec): Float
```

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.

### multiply

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

```
fun multiply(lhs: Float, rhs: Vec, output: MutableVec): Unit
```

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

### multiply

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

```
fun multiply(lhs: Vec, rhs: Float, output: MutableVec): Unit
```

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

### signedAngleBetweenInDegrees

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

```
fun signedAngleBetweenInDegrees(lhs: Vec, rhs: Vec): @AngleDegreesFloat @FloatRange(from = -180.0, to = 180.0, fromInclusive = false) Float
```

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

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

```
fun subtract(lhs: Vec, rhs: Vec, output: MutableVec): Unit
```

Subtracts the x and y values of `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/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/kotlin/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)` or `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec.Companion#subtract(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.MutableVec)`.

## Public companion properties

### ORIGIN

Cmn

```
val ORIGIN: ImmutableVec
```

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

## Public functions

### computeDirectionDegrees

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

```
fun computeDirectionDegrees(): @FloatRange(from = -180.0, to = 180.0) @AngleDegreesFloat Float
```

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

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

```
fun computeMagnitude(): @FloatRange(from = 0.0) Float
```

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

### computeMagnitudeSquared

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

```
fun computeMagnitudeSquared(): @FloatRange(from = 0.0) Float
```

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

### computeNegation

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

```
fun computeNegation(): ImmutableVec
```

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/kotlin/androidx/ink/geometry/Vec#computeNegation()` with a pre-allocated instance of `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec`.

### computeNegation

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

```
fun computeNegation(outVec: MutableVec): MutableVec
```

Modifies `https://developer.android.com/reference/kotlin/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/kotlin/androidx/ink/geometry/Vec#computeNegation(androidx.ink.geometry.MutableVec)`.

### computeOrthogonal

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

```
fun computeOrthogonal(): ImmutableVec
```

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/kotlin/androidx/ink/geometry/Vec#computeOrthogonal()` with a pre-allocated instance of `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec`.

### computeOrthogonal

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

```
fun computeOrthogonal(outVec: MutableVec): MutableVec
```

Modifies `https://developer.android.com/reference/kotlin/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/kotlin/androidx/ink/geometry/Vec#computeOrthogonal(androidx.ink.geometry.MutableVec)`.

### computeUnitVec

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

```
fun computeUnitVec(): ImmutableVec
```

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/kotlin/androidx/ink/geometry/ImmutableVec#fromDirectionInDegreesAndMagnitude(kotlin.Float,kotlin.Float)` with `https://developer.android.com/reference/kotlin/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/kotlin/androidx/ink/geometry/Vec#computeUnitVec()` with a pre-allocated instance of `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec`.

### computeUnitVec

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

```
fun computeUnitVec(outVec: MutableVec): MutableVec
```

Modifies `https://developer.android.com/reference/kotlin/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/kotlin/androidx/ink/geometry/Vec#computeUnitVec(androidx.ink.geometry.MutableVec)`. This is equivalent to (but faster than) calling `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#populateFromDirectionInDegreesAndMagnitude(kotlin.Float,kotlin.Float)` with `https://developer.android.com/reference/kotlin/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.

### isAlmostEqual

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

```
fun isAlmostEqual(other: Vec, tolerance: @FloatRange(from = 0.0) Float = 1.0E-4f): Boolean
```

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

### isParallelTo

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

```
fun isParallelTo(
    other: Vec,
    toleranceDegrees: @AngleDegreesFloat @FloatRange(from = 0.0) Float
): Boolean
```

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

### isPerpendicularTo

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

```
fun isPerpendicularTo(
    other: Vec,
    toleranceDegrees: @AngleDegreesFloat @FloatRange(from = 0.0) Float
): Boolean
```

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

### toImmutable

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

```
abstract fun toImmutable(): ImmutableVec
```

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

## Public properties

### x

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

```
abstract val x: Float
```

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

### y

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

```
abstract val y: Float
```

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

## Extension functions

### Vec.populatePointF

android 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)

```
fun Vec.populatePointF(out: PointF): PointF
```

Writes the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` to `https://developer.android.com/reference/kotlin/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/android/graphics/PointF.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Vec).populatePointF(android.graphics.PointF)` |

### Vec.toPointF

android 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)

```
fun Vec.toPointF(): PointF
```

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

### Vec.toOffset

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

```
fun Vec.toOffset(): Offset
```

Returns an `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` with the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec`.