Stay organized with collections
Save and categorize content based on your preferences.
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
Public methods |
boolean |
|
static final @NonNull ImmutableVec |
Returns an ImmutableVec with the given magnitude and direction in degrees rotated from the positive x-axis in the direction of positive y-axis.
|
float |
The Vec's offset in the x-direction
|
float |
The Vec's offset in the y-direction
|
int |
|
@NonNull String |
|
Inherited methods |
From androidx.ink.geometry.Vec
final @FloatRange(from = -180.0, to = 180.0) @AngleDegreesFloat float |
The angle between the positive x-axis and this vec, in the direction of the positive y-axis.
|
final @FloatRange(from = 0.0) float |
The length of the Vec.
|
final @FloatRange(from = 0.0) float |
The squared length of the Vec.
|
final @NonNull ImmutableVec |
Returns a newly allocated vector with the same magnitude, but pointing in the opposite direction.
|
final @NonNull MutableVec |
Modifies outVec into a vector with the same magnitude, but pointing in the opposite direction.
|
final @NonNull ImmutableVec |
Returns a newly allocated vector with the same magnitude as this one, but rotated by (positive) 90 degrees.
|
final @NonNull MutableVec |
Modifies outVec into a vector with the same magnitude as this one, but rotated by (positive) 90 degrees.
|
final @NonNull ImmutableVec |
Returns a newly allocated vector with the same direction as this one, but with a magnitude of 1.
|
final @NonNull MutableVec |
Modifies outVec into a vector with the same direction as this one, but with a magnitude of 1.
|
final boolean |
Compares this Vec with other, and returns true if the difference between x and other.x is less than tolerance, and likewise for y.
|
final boolean |
Returns true if the angle formed by this and other is within toleranceDegrees of 0 degrees or 180 degrees.
|
final boolean |
Returns true if the angle formed by this and other is within toleranceDegrees of ±90 degrees.
|
|
Public methods
public float getX()
The Vec's offset in the x-direction
public float getY()
The Vec's offset in the y-direction
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-11-19 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-11-19 UTC."],[],[]]