ImmutableVec
public final class ImmutableVec extends Vec
An immutable two-dimensional vector, i.e. an (x, y) coordinate pair. It can be used to represent either:
-
A two-dimensional offset, i.e. the difference between two points
-
A point in space, i.e. treating the vector as an offset from the origin
This object is immutable, so it is inherently thread-safe. See MutableVec for a mutable alternative.
Summary
Nested types |
|---|
public static class ImmutableVec.Companion |
Public constructors |
|---|
ImmutableVec(float x, float y) |
Public methods |
|
|---|---|
boolean |
|
static final @NonNull ImmutableVec |
fromDirectionInDegreesAndMagnitude(Returns an |
float |
getX()The |
float |
getY()The |
int |
hashCode() |
@NonNull ImmutableVec |
Returns an immutable copy of this object. |
@NonNull String |
toString() |
Inherited methods |
||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
Public methods
fromDirectionInDegreesAndMagnitude
public static final @NonNull ImmutableVec fromDirectionInDegreesAndMagnitude(
@AngleDegreesFloat float directionDegrees,
float magnitude
)
Returns an ImmutableVec with the given magnitude and direction in degrees rotated from the positive x-axis in the direction of positive y-axis.
toImmutable
public @NonNull ImmutableVec toImmutable()
Returns an immutable copy of this object. This will return itself if called on an immutable instance.