# ImmutableSegment

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

*** ** * ** ***


```
public final class ImmutableSegment extends Segment
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.ink.geometry.Segment](https://developer.android.com/reference/androidx/ink/geometry/Segment) ||
|   | ↳ | [androidx.ink.geometry.ImmutableSegment](https://developer.android.com/reference/androidx/ink/geometry/ImmutableSegment) |

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/ink/geometry/ImmutableSegment#ImmutableSegment(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 start, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec end)` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableSegment#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `@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/ImmutableSegment#getEnd()()` |
| `@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/ImmutableSegment#getStart()()` |
| `int` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableSegment#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableSegment` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableSegment#toImmutable()()` Returns an immutable copy of this object. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableSegment#toString()()` |

| ### Inherited methods |
|---|
| From [androidx.ink.geometry.Segment](https://developer.android.com/reference/androidx/ink/geometry/Segment) |---|---| | `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/Segment#computeBoundingBox()()` Returns the minimum bounding box containing the `https://developer.android.com/reference/androidx/ink/geometry/Segment`. | | `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/Segment#computeBoundingBox(androidx.ink.geometry.MutableBox)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableBox outBox)` Populates `https://developer.android.com/reference/androidx/ink/geometry/Segment#computeBoundingBox(androidx.ink.geometry.MutableBox)` with the minimum bounding box containing the `https://developer.android.com/reference/androidx/ink/geometry/Segment`. | | `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/Segment#computeDisplacement()()` Returns an ImmutableVec with the displacement from start to end. | | `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/Segment#computeDisplacement(androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVec)` Populates `https://developer.android.com/reference/androidx/ink/geometry/Segment#computeDisplacement(androidx.ink.geometry.MutableVec)` with the displacement from start to end. | | `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/ink/geometry/Segment#computeLength()()` The length of the `https://developer.android.com/reference/androidx/ink/geometry/Segment`. | | `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/Segment#computeLerpPoint(kotlin.Float)(float ratio)` Returns the point on the segment at the given ratio of the segment's length, measured from the start point. | | `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/Segment#computeLerpPoint(kotlin.Float,androidx.ink.geometry.MutableVec)(float ratio, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVec)` Fills `https://developer.android.com/reference/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. | | `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/Segment#computeMidpoint()()` Returns an `https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` that lies halfway along the segment. | | `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/Segment#computeMidpoint(androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVec)` Populates `https://developer.android.com/reference/androidx/ink/geometry/Segment#computeMidpoint(androidx.ink.geometry.MutableVec)` with the point halfway along the segment. | | `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/Segment#isAlmostEqual(androidx.ink.geometry.Segment,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Segment other, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float tolerance )` Compares this `https://developer.android.com/reference/androidx/ink/geometry/Segment` with `https://developer.android.com/reference/androidx/ink/geometry/Segment#isAlmostEqual(androidx.ink.geometry.Segment,kotlin.Float)`, and returns true if both `https://developer.android.com/reference/androidx/ink/geometry/Segment#start()` points are considered almost equal with the given `https://developer.android.com/reference/androidx/ink/geometry/Segment#isAlmostEqual(androidx.ink.geometry.Segment,kotlin.Float)`, and likewise for both `https://developer.android.com/reference/androidx/ink/geometry/Segment#end()` points. | | `final float` | `https://developer.android.com/reference/androidx/ink/geometry/Segment#project(androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec pointToProject)` Returns the multiple of the segment's length at which the infinite extrapolation of this segment is closest to `https://developer.android.com/reference/androidx/ink/geometry/Segment#project(androidx.ink.geometry.Vec)`. | |

## Public constructors

### ImmutableSegment

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

```
public ImmutableSegment(@NonNull Vec start, @NonNull Vec end)
```

## Public methods

### equals

```
public boolean equals(Object other)
```

### getEnd

```
public @NonNull ImmutableVec getEnd()
```

### getStart

```
public @NonNull ImmutableVec getStart()
```

### hashCode

```
public int hashCode()
```

### toImmutable

```
public @NonNull ImmutableSegment toImmutable()
```

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

### toString

```
public @NonNull String toString()
```