# MutableVec

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/MutableVec.kt+class:androidx.ink.geometry.MutableVec) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

  ```
  class MutableVec : Vec
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.ink.geometry.Vec](https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec) ||
|   | ↳ | [androidx.ink.geometry.MutableVec](https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec) |

*** ** * ** ***

A mutable 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

This object is mutable and is not inherently thread-safe, so callers should apply their own synchronization logic or use this object from a single thread. See `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` for an immutable alternative.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#MutableVec()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#MutableVec(kotlin.Float,kotlin.Float)(x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` | Cmn |

| ### Public functions |
|---|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#hashCode()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#populateFrom(androidx.ink.geometry.Vec)(input: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Fills this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` with the same values contained in `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#populateFrom(androidx.ink.geometry.Vec)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#populateFromDirectionInDegreesAndMagnitude(kotlin.Float,kotlin.Float)( directionDegrees: @https://developer.android.com/reference/kotlin/androidx/ink/geometry/AngleDegreesFloat https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, magnitude: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Fills this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` to have the given magnitude and direction in degrees rotated from the positive x-axis in the direction of positive y-axis. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#toImmutable()()` Returns an immutable copy of this object. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#x()` The `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec`'s offset in the x-direction | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#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/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec.https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#(androidx.ink.geometry.MutableVec).populateFrom(android.graphics.PointF)(point: https://developer.android.com/reference/android/graphics/PointF.html)` Fills this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` with the values from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.MutableVec).populateFrom(android.graphics.PointF)`. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec.https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#(androidx.ink.geometry.MutableVec).populateFrom(androidx.compose.ui.geometry.Offset)(offset: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` Writes the values from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.MutableVec).populateFrom(androidx.compose.ui.geometry.Offset)` to this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec`. | android |

### Inherited functions

From [androidx.ink.geometry.Vec](https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec) `@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

## Public constructors

### MutableVec

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

```
MutableVec()
```

### MutableVec

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

```
MutableVec(x: Float, y: Float)
```

## Public functions

### equals

Cmn

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```

### populateFrom

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

```
fun populateFrom(input: Vec): MutableVec
```

Fills this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` with the same values contained in `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec#populateFrom(androidx.ink.geometry.Vec)`.

### populateFromDirectionInDegreesAndMagnitude

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

```
fun populateFromDirectionInDegreesAndMagnitude(
    directionDegrees: @AngleDegreesFloat Float,
    magnitude: Float
): MutableVec
```

Fills this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` to have the given magnitude and direction in degrees rotated from the positive x-axis in the direction of positive y-axis.

### toImmutable

Cmn

```
open fun toImmutable(): ImmutableVec
```

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

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### x

Cmn

```
open var x: Float
```

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

### y

Cmn

```
open var y: Float
```

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

## Extension functions

### MutableVec.populateFrom

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:populateFrom)

```
fun MutableVec.populateFrom(point: PointF): MutableVec
```

Fills this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` with the values from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.MutableVec).populateFrom(android.graphics.PointF)`.

Leaves `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.MutableVec).populateFrom(android.graphics.PointF)` unchanged. Returns the modified instance to allow chaining calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `this` |

### MutableVec.populateFrom

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:populateFrom)

```
fun MutableVec.populateFrom(offset: Offset): MutableVec
```

Writes the values from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.MutableVec).populateFrom(androidx.compose.ui.geometry.Offset)` to this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `this` |