# Triangle

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

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

  ```
  abstract class Triangle
  ```
Known direct subclasses [ImmutableTriangle](https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableTriangle), [MutableTriangle](https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableTriangle)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableTriangle` | An immutable triangle, defined by its three corners `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableTriangle#(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)`, `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableTriangle#(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableTriangle#(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)` in order. |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableTriangle` | Represents a mutable triangle, defined by its three corners `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableTriangle#p0()`, `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableTriangle#p1()` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableTriangle#p2()` in order. |

*** ** * ** ***

A triangle defined by its three corners `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#p0()`, `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#p1()` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#p2()`. The order of these points matter - a triangle with p0, p1, p2 is not the same as the permuted p1, p0, p2, or even the rotated p2, p0, p1.

A `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle` may be degenerate, meaning it is constructed with its 3 points colinear. One way that a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle` may be degenerate is if two or three of its points are at the same location (coincident).

This is a read-only interface that has mutable and immutable implementations. See `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableTriangle` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableTriangle`.

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableBox` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeBoundingBox()()` Returns the minimum bounding box containing the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableBox` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#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/Triangle#computeBoundingBox(androidx.ink.geometry.MutableBox)` with the minimum bounding box containing the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle` and returns `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeBoundingBox(androidx.ink.geometry.MutableBox)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableSegment` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int)(index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 2) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the segment of the Triangle between the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int)` and the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int)` + 1 modulo 3. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)(index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 2) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, outSegment: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableSegment)` Fills `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)` with the segment of the Triangle between the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)` and the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)` + 1 modulo 3. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeSignedArea()()` Return the signed area of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`. | Cmn |
| `operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#contains(androidx.ink.geometry.Vec)(point: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Returns true if the given point is contained within the Triangle. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#isAlmostEqual(androidx.ink.geometry.Triangle,kotlin.Float)(other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle, tolerance: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` | Cmn |
| `abstract https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableTriangle` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#toImmutable()()` Returns an immutable copy of this object. | Cmn |

| ### Public properties |
|---|---|---|
| `abstract https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#p0()` One of the three points that define the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`. | Cmn |
| `abstract https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#p1()` One of the three points that define the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`. | Cmn |
| `abstract https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#p2()` One of the three points that define the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`. | Cmn |

## Public functions

### computeBoundingBox

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

```
fun computeBoundingBox(): ImmutableBox
```

Returns the minimum bounding box containing the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`.

### computeBoundingBox

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

```
fun computeBoundingBox(outBox: MutableBox): MutableBox
```

Populates `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeBoundingBox(androidx.ink.geometry.MutableBox)` with the minimum bounding box containing the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle` and returns `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeBoundingBox(androidx.ink.geometry.MutableBox)`.

### computeEdge

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

```
fun computeEdge(index: @IntRange(from = 0, to = 2) Int): ImmutableSegment
```

Returns the segment of the Triangle between the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int)` and the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int)` + 1 modulo 3.

### computeEdge

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

```
fun computeEdge(index: @IntRange(from = 0, to = 2) Int, outSegment: MutableSegment): MutableSegment
```

Fills `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)` with the segment of the Triangle between the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)` and the point at `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)` + 1 modulo 3. Returns `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle#computeEdge(kotlin.Int,androidx.ink.geometry.MutableSegment)`.

### computeSignedArea

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

```
fun computeSignedArea(): Float
```

Return the signed area of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`. If the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle` is degenerate, meaning its 3 points are all colinear, then the result will be zero. If its points wind in a positive direction (as defined by `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Angle`), then the result will be positive. Otherwise, it will be negative.

### contains

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

```
operator fun contains(point: Vec): Boolean
```

Returns true if the given point is contained within the Triangle. Points that lie exactly on the Triangle's boundary are considered to be contained.

### isAlmostEqual

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

```
fun isAlmostEqual(other: Triangle, tolerance: @FloatRange(from = 0.0) Float): Boolean
```

### toImmutable

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

```
abstract fun toImmutable(): ImmutableTriangle
```

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

## Public properties

### p0

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

```
abstract val p0: Vec
```

One of the three points that define the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`.

### p1

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

```
abstract val p1: Vec
```

One of the three points that define the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`.

### p2

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

```
abstract val p2: Vec
```

One of the three points that define the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle`.