MutableSegment


public final class MutableSegment extends Segment


Represents a mutable directed line segment between two points. See ImmutableSegment for the immutable alternative.

Summary

Public constructors

Constructs a degenerate MutableSegment with both start and end set to (0f, 0f)

Create the MutableSegment from two existing MutableVec instances.

Public methods

boolean
equals(Object other)
@NonNull MutableVec
@NonNull MutableVec
int
final @NonNull MutableSegment

Fills this MutableSegment with the same values contained in input and returns this.

void
void
@NonNull String

Inherited methods

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

Returns the minimum bounding box containing the Segment.

final @NonNull MutableBox

Populates outBox with the minimum bounding box containing the Segment.

final @NonNull ImmutableVec

Returns an ImmutableVec with the displacement from start to end.

final @NonNull MutableVec

Populates outVec with the displacement from start to end.

final @FloatRange(from = 0.0) float

The length of the Segment.

final @NonNull ImmutableVec
computeLerpPoint(float ratio)

Returns the point on the segment at the given ratio of the segment's length, measured from the start point.

final @NonNull MutableVec
computeLerpPoint(float ratio, @NonNull MutableVec outVec)

Fills outVec with the point on the segment at the given ratio of the segment's length, measured from the start point.

final @NonNull ImmutableVec

Returns an ImmutableVec that lies halfway along the segment.

final @NonNull MutableVec

Populates outVec with the point halfway along the segment.

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

Compares this Segment with other, and returns true if both start points are considered almost equal with the given tolerance, and likewise for both end points.

final float
project(@NonNull Vec pointToProject)

Returns the multiple of the segment's length at which the infinite extrapolation of this segment is closest to pointToProject.

Public constructors

MutableSegment

Added in 1.0.0-alpha02
public MutableSegment()

Constructs a degenerate MutableSegment with both start and end set to (0f, 0f)

MutableSegment

Added in 1.0.0-alpha02
public MutableSegment(@NonNull MutableVec start, @NonNull MutableVec end)

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

Public methods

equals

public boolean equals(Object other)

getEnd

Added in 1.0.0-alpha02
public @NonNull MutableVec getEnd()

getStart

Added in 1.0.0-alpha02
public @NonNull MutableVec getStart()

hashCode

public int hashCode()

populateFrom

Added in 1.0.0-alpha02
public final @NonNull MutableSegment populateFrom(@NonNull Segment input)

Fills this MutableSegment with the same values contained in input and returns this.

setEnd

Added in 1.0.0-alpha02
public void setEnd(@NonNull MutableVec end)

setStart

Added in 1.0.0-alpha02
public void setStart(@NonNull MutableVec start)

toString

public @NonNull String toString()