Basics
Guides
API Reference
Basics
Guides
API Reference
[18:7] extends: Poolable
Wraps FXGL's Vec2 (com.almasb.fxgl.core.math.Vec2), the libgdx-derived 2D float vector used throughout the FXGL physics, particle, and entity APIs. Aussom users mostly encounter Vec2 as the parameter or return type of Entity.setPosition, Entity.translate, World.getBodies positions, HitBox axes, and PhysicsUnitConverter helpers. Methods that mutate (set, add, sub, mul, normalize) follow the FXGL convention of returning this so calls chain.
Vec2 (double X = 0.0, double Y = 0.0)
Creates a new Vec2 with the given X and Y components.
X is a double with the X component.Y is a double with the Y component.getX ()
Returns the X component (Vec2 stores X as a public float field).
A double with the X value.getY ()
Returns the Y component (Vec2 stores Y as a public float field).
A double with the Y value.set (double X, double Y)
Sets both components.
X is a double with the new X.Y is a double with the new Y.this objectsetVec (object Other)
Copies another Vec2 into this one in place.
Other is a Vec2 wrapper.this objectsetPoint (object PointObj)
Copies a JavaFX Point2D into this vector in place.
PointObj is a fx.Point2D wrapper (or any AussomJavaObject around a javafx.geometry.Point2D).this objectsetZero ()
Zeros both components in place.
this objectsetFromAngle (double Degrees)
Sets this vector from a polar angle in degrees, producing a unit-length vector pointing along that angle.
Degrees is the angle in degrees from the +X axis.this objectcopy ()
Returns a fresh copy of this vector.
A new Vec2 wrapper.toPoint2D ()
Returns the vector as an AussomJavaObject around a JavaFX Point2D so it can be passed to any FXGL API that expects a Point2D.
An AussomJavaObject around a Point2D.adopt (object Ajo)
Wraps an existing Vec2 AussomJavaObject as a new wrapper. Used internally when an immutable operation returns a fresh Vec2 from the underlying FXGL method.
Ajo is an AussomJavaObject around a Vec2.A new Vec2 wrapper.addLocal (double X, double Y)
Adds the given X, Y to this vector in place.
X is a double with the X to add.Y is a double with the Y to add.this objectaddLocalVec (object Other)
Adds another Vec2 to this one in place.
Other is a Vec2 wrapper.this objectsubLocal (double X, double Y)
Subtracts the given X, Y from this vector in place.
X is a double with the X to subtract.Y is a double with the Y to subtract.this objectsubLocalVec (object Other)
Subtracts another Vec2 from this one in place.
Other is a Vec2 wrapper.this objectmulLocal (double A)
Multiplies this vector by the given scalar in place.
A is a double scalar.this objectadd (double X, double Y)
Returns a new Vec2 equal to (this.x + X, this.y + Y), leaving this vector unchanged.
X is a double with the X to add.Y is a double with the Y to add.A new Vec2 wrapper.addVec (object Other)
Returns a new Vec2 equal to this + Other, leaving this vector unchanged.
Other is a Vec2 wrapper.A new Vec2 wrapper.sub (double X, double Y)
Returns a new Vec2 equal to (this.x - X, this.y - Y), leaving this vector unchanged.
X is a double with the X to subtract.Y is a double with the Y to subtract.A new Vec2 wrapper.subVec (object Other)
Returns a new Vec2 equal to this - Other, leaving this vector unchanged.
Other is a Vec2 wrapper.A new Vec2 wrapper.mul (double A)
Returns a new Vec2 equal to this * A, leaving this vector unchanged.
A is a double scalar.A new Vec2 wrapper.negate ()
Returns a new Vec2 equal to -this (negated components), leaving this vector unchanged.
A new Vec2 wrapper.negateLocal ()
Negates this vector in place.
this objectnormalizeLocal ()
Normalizes this vector in place (to unit length).
this objectnormalize ()
Returns a unit-length copy of this vector, leaving this vector unchanged. A zero vector normalizes to (0, 0).
A new Vec2 wrapper.setLength (double Length)
Scales this vector in place so its length equals the given value.
Length is the target magnitude.this objectgetLengthAndNormalize ()
Normalizes this vector in place and returns its prior length in one call. Useful when you need both the unit vector and the original magnitude.
A double with the prior length.length ()
Returns the vector length.
A double with the magnitude.lengthSquared ()
Returns the squared vector length (faster, avoids sqrt).
A double with the squared magnitude.distance (object Other)
Returns the distance from this vector to the given Vec2.
Other is a Vec2 to measure to.A double with the distance.angle ()
Returns the angle (in degrees) of this vector relative to the X axis.
A double with the angle.angleTo (object Other)
Returns the angle (in degrees) from this vector to Other.
Other is a Vec2 wrapper.A double.perpendicularCCW ()
Returns a new Vec2 rotated 90 degrees counter-clockwise from this vector, leaving this unchanged. Common in 2D physics for computing tangents and side vectors.
A new Vec2 wrapper.perpendicularCW ()
Returns a new Vec2 rotated 90 degrees clockwise from this vector, leaving this unchanged.
A new Vec2 wrapper.midpoint (object Other)
Returns a new Vec2 at the midpoint between this and Other.
Other is a Vec2 wrapper.A new Vec2 wrapper.abs ()
Returns a new Vec2 with the absolute value of each component, leaving this vector unchanged.
A new Vec2 wrapper.absLocal ()
Takes the absolute value of each component in place.
this objectisNearlyEqualTo (object Other)
Returns true when this vector is component-wise nearly equal to Other within FXGL's default tolerance. Other is converted to a Point2D internally because the upstream API operates on Point2D rather than Vec2.
Other is a Vec2 wrapper.A bool.isCloseTo (object Other, double Tolerance)
Returns true when this vector is within Tolerance of Other. Other is converted to a Point2D internally because the upstream API operates on Point2D rather than Vec2.
Other is a Vec2 wrapper.Tolerance is the per-component tolerance.A bool.fromAngle (double Degrees)
Builds a Vec2 from a polar angle in degrees, producing a unit-length vector pointing along that angle. Static helper.
Degrees is the angle in degrees from the +X axis.A new Vec2 wrapper.dot (object A, object B)
Returns the dot product of two Vec2s. Static helper.
A is a Vec2 wrapper.B is a Vec2 wrapper.A double.cross (object A, object B)
Returns the 2D cross product of two Vec2s (a scalar; the Z component of the 3D cross). Static helper.
A is a Vec2 wrapper.B is a Vec2 wrapper.A double.distanceSquared (object Other)
Returns the squared distance to Other. Cheaper than distance() when only comparison matters.
reset ()
Zeroes this Vec2 in place. Equivalent to setZero().

Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.