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(Create the |
Public methods |
|
|---|---|
boolean |
Equality for |
@NonNull MutableVec |
getP0()One of the three points that define the |
@NonNull MutableVec |
getP1()One of the three points that define the |
@NonNull MutableVec |
getP2()One of the three points that define the |
int |
hashCode() |
final @NonNull MutableTriangle |
populateFrom(@NonNull Triangle input)Fills this |
void |
setP0(@NonNull MutableVec p0)One of the three points that define the |
void |
setP1(@NonNull MutableVec p1)One of the three points that define the |
void |
setP2(@NonNull MutableVec p2)One of the three points that define the |
@NonNull String |
toString() |
Inherited methods |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MutableTriangle
public MutableTriangle()
Constructs a degenerate MutableTriangle with p0, p1, and p2 set to (0, 0).
MutableTriangle
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.
populateFrom
public final @NonNull MutableTriangle populateFrom(@NonNull Triangle input)
Fills this MutableTriangle with the values from input.
Returns the modified instance to allow chaining calls.
| Returns | |
|---|---|
@NonNull MutableTriangle |
|
setP0
public void setP0(@NonNull MutableVec p0)
One of the three points that define the Triangle.
setP1
public void setP1(@NonNull MutableVec p1)
One of the three points that define the Triangle.
setP2
public void setP2(@NonNull MutableVec p2)
One of the three points that define the Triangle.