# MutableSegment

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

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

  ```
  class MutableSegment : Segment
  ```

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

*** ** * ** ***

Represents a mutable directed line segment between two points. See `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableSegment` for the immutable alternative.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#MutableSegment()()` Constructs a degenerate `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` with both `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#start()` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#end()` set to (0f, 0f) | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#MutableSegment(androidx.ink.geometry.MutableVec,androidx.ink.geometry.MutableVec)(start: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec, end: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Create the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` from two existing `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` instances. | 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/MutableSegment#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/MutableSegment#hashCode()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#populateFrom(androidx.ink.geometry.Segment)(input: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment)` Fills this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` with the same values contained in `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#populateFrom(androidx.ink.geometry.Segment)`. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableSegment` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#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/MutableSegment#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#end()` | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#start()` | Cmn |

### Inherited functions

From [androidx.ink.geometry.Segment](https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment) `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableBox` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeBoundingBox()()`

Returns the minimum bounding box containing the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment`.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableBox` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeBoundingBox(androidx.ink.geometry.MutableBox)(outBox: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableBox)`

Populates `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeBoundingBox(androidx.ink.geometry.MutableBox)` with the minimum bounding box containing the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment`.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeDisplacement()()`

Returns an ImmutableVec with the displacement from start to end.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeDisplacement(androidx.ink.geometry.MutableVec)(outVec: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)`

Populates `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeDisplacement(androidx.ink.geometry.MutableVec)` with the displacement from start to end.
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/Segment#computeLength()()`

The length of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment`.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeLerpPoint(kotlin.Float)(ratio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Returns the point on the segment at the given ratio of the segment's length, measured from the start point.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeLerpPoint(kotlin.Float,androidx.ink.geometry.MutableVec)(ratio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, outVec: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)`

Fills `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeLerpPoint(kotlin.Float,androidx.ink.geometry.MutableVec)` with the point on the segment at the given ratio of the segment's length, measured from the start point.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeMidpoint()()`

Returns an `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` that lies halfway along the segment.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeMidpoint(androidx.ink.geometry.MutableVec)(outVec: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)`

Populates `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#computeMidpoint(androidx.ink.geometry.MutableVec)` with the point halfway along the segment.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#isAlmostEqual(androidx.ink.geometry.Segment,kotlin.Float)(other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment, 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/Segment` with `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#isAlmostEqual(androidx.ink.geometry.Segment,kotlin.Float)`, and returns true if both `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#start()` points are considered almost equal with the given `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#isAlmostEqual(androidx.ink.geometry.Segment,kotlin.Float)`, and likewise for both `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#end()` points.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#project(androidx.ink.geometry.Vec)(pointToProject: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)`

Returns the multiple of the segment's length at which the infinite extrapolation of this segment is closest to `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment#project(androidx.ink.geometry.Vec)`.
Cmn

## Public constructors

### MutableSegment

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

```
MutableSegment()
```

Constructs a degenerate `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` with both `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#start()` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment#end()` set to (0f, 0f)

### MutableSegment

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

```
MutableSegment(start: MutableVec, end: MutableVec)
```

Create the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` from two existing `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` instances. Note that these instances will become the internal state of this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment`, so modifications made to them directly or through setters on this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` will modify the input `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` instances too. This is to allow performance-critical code to avoid any unnecessary allocations. This can be tricky to manage, especially in multithreaded code, so when calling code is unable to guarantee ownership of the nested mutable data at a particular time, it may be safest to construct this with copies of the data to give this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` exclusive ownership of those copies.

## 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: Segment): MutableSegment
```

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

Returns the modified instance to allow chaining calls.

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

### toImmutable

Cmn

```
open fun toImmutable(): ImmutableSegment
```

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

### end

Cmn

```
open var end: MutableVec
```

### start

Cmn

```
open var start: MutableVec
```