MutableTriangle


public final class MutableTriangle extends Triangle


Represents a mutable triangle, defined by its three corners p0, p1 and p2 in order. See ImmutableTriangle for the immutable version.

Summary

Public constructors

Constructs a degenerate MutableTriangle with p0, p1, and p2 set to (0, 0).

MutableTriangle(
    @NonNull MutableVec p0,
    @NonNull MutableVec p1,
    @NonNull MutableVec p2
)

Create the MutableTriangle from three existing MutableVec instances.

Public methods

boolean
equals(Object other)

Equality for MutableTriangle is defined using the order in which p0, p1 and p2 are defined.

@NonNull MutableVec

One of the three points that define the Triangle.

@NonNull MutableVec

One of the three points that define the Triangle.

@NonNull MutableVec

One of the three points that define the Triangle.

int
final @NonNull MutableTriangle

Copies the points from input to this MutableTriangle and returns this.

void

One of the three points that define the Triangle.

void

One of the three points that define the Triangle.

void

One of the three points that define the Triangle.

@NonNull String

Inherited methods

From androidx.ink.geometry.Triangle
final @NonNull ImmutableBox

Returns the minimum bounding box containing the Triangle.

final @NonNull MutableBox

Populates outBox with the minimum bounding box containing the Triangle and returns outBox.

final @NonNull ImmutableSegment
computeEdge(@IntRange(from = 0, to = 2) int index)

Returns the segment of the Triangle between the point at index and the point at index + 1 modulo 3.

final @NonNull MutableSegment
computeEdge(
    @IntRange(from = 0, to = 2) int index,
    @NonNull MutableSegment outSegment
)

Fills outSegment with the segment of the Triangle between the point at index and the point at index + 1 modulo 3.

final float

Return the signed area of the Triangle.

final boolean

Returns true if the given point is contained within the Triangle.

final boolean
isAlmostEqual(
    @NonNull Triangle other,
    @FloatRange(from = 0.0) float tolerance
)

Public constructors

MutableTriangle

Added in 1.0.0-alpha01
public MutableTriangle()

Constructs a degenerate MutableTriangle with p0, p1, and p2 set to (0, 0).

MutableTriangle

Added in 1.0.0-alpha01
public MutableTriangle(
    @NonNull MutableVec p0,
    @NonNull MutableVec p1,
    @NonNull MutableVec p2
)

Create the MutableTriangle from three existing MutableVec instances. Note that these instances will become the internal state of this MutableTriangle, so modifications made to them directly or through setters on this MutableTriangle will modify the input 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 MutableTriangle exclusive ownership of those copies.

Public methods

equals

public boolean equals(Object other)

Equality for MutableTriangle is defined using the order in which p0, p1 and p2 are defined. Rotated/flipped triangles with out-of-order vertices are not considered equal.

getP0

Added in 1.0.0-alpha01
public @NonNull MutableVec getP0()

One of the three points that define the Triangle.

getP1

Added in 1.0.0-alpha01
public @NonNull MutableVec getP1()

One of the three points that define the Triangle.

getP2

Added in 1.0.0-alpha01
public @NonNull MutableVec getP2()

One of the three points that define the Triangle.

hashCode

public int hashCode()

populateFrom

Added in 1.0.0-alpha01
public final @NonNull MutableTriangle populateFrom(@NonNull Triangle input)

Copies the points from input to this MutableTriangle and returns this.

setP0

Added in 1.0.0-alpha01
public void setP0(@NonNull MutableVec p0)

One of the three points that define the Triangle.

setP1

Added in 1.0.0-alpha01
public void setP1(@NonNull MutableVec p1)

One of the three points that define the Triangle.

setP2

Added in 1.0.0-alpha01
public void setP2(@NonNull MutableVec p2)

One of the three points that define the Triangle.

toString

public @NonNull String toString()