public final class Vec2 extends Object implements Serializable, Poolable
| Constructor and Description |
|---|
Vec2() |
Vec2(double x,
double y)
Convenience ctor for double values.
|
Vec2(float x,
float y) |
Vec2(javafx.geometry.Point2D toCopy) |
Vec2(Vec2 toCopy) |
| Modifier and Type | Method and Description |
|---|---|
Vec2 |
abs() |
static Vec2 |
abs(Vec2 a) |
Vec2 |
absLocal()
Modify this vector to have only positive components.
|
static void |
absToOut(Vec2 a,
Vec2 out) |
Vec2 |
add(double otherX,
double otherY)
Return the sum of this vector and another; does not alter either one.
|
Vec2 |
add(javafx.geometry.Point2D vector)
Return the sum of this vector and another; does not alter either one.
|
Vec2 |
add(Vec2 v)
Return the sum of this vector and another; does not alter either one.
|
Vec2 |
addLocal(double x,
double y)
Adds values to this vector and returns result - alters this vector.
|
Vec2 |
addLocal(Vec2 v)
Add another vector to this one and returns result - alters this vector.
|
float |
angle() |
float |
angle(double otherX,
double otherY) |
float |
angle(javafx.geometry.Point2D other) |
float |
angle(Vec2 other) |
Vec2 |
clone() |
Vec2 |
copy() |
static Vec2 |
cross(float s,
Vec2 a) |
static Vec2 |
cross(Vec2 a,
float s) |
static float |
cross(Vec2 a,
Vec2 b) |
static void |
crossToOut(float s,
Vec2 a,
Vec2 out) |
static void |
crossToOut(Vec2 a,
float s,
Vec2 out) |
static void |
crossToOutUnsafe(float s,
Vec2 a,
Vec2 out) |
static void |
crossToOutUnsafe(Vec2 a,
float s,
Vec2 out) |
double |
distance(double otherX,
double otherY) |
double |
distance(javafx.geometry.Point2D other) |
double |
distance(Vec2 other) |
boolean |
distanceGreaterThanOrEqual(double otherX,
double otherY,
double distance) |
boolean |
distanceLessThanOrEqual(double otherX,
double otherY,
double distance) |
double |
distanceSquared(double otherX,
double otherY) |
static float |
dot(Vec2 a,
Vec2 b) |
boolean |
equals(Object obj) |
boolean |
equalsPoint2D(javafx.geometry.Point2D p) |
static Vec2 |
fromAngle(double degrees) |
int |
hashCode() |
boolean |
isValid()
True if the vector represents a pair of valid, non-infinite floating point numbers.
|
float |
length() |
float |
lengthSquared() |
static Vec2 |
max(Vec2 a,
Vec2 b) |
static void |
maxToOut(Vec2 a,
Vec2 b,
Vec2 out) |
Vec2 |
midpoint(javafx.geometry.Point2D other) |
Vec2 |
midpoint(Vec2 other) |
static Vec2 |
min(Vec2 a,
Vec2 b) |
static void |
minToOut(Vec2 a,
Vec2 b,
Vec2 out) |
Vec2 |
mul(double a)
Return this vector multiplied by a scalar; does not alter this vector.
|
Vec2 |
mulLocal(double a)
Multiply this vector by a number and return result - alters this vector.
|
Vec2 |
negate()
Return the negation of this vector; does not alter this vector.
|
Vec2 |
negateLocal()
Flip the vector and return it - alters this vector.
|
static void |
negateToOut(Vec2 a,
Vec2 out) |
float |
normalize()
Normalize this vector and return the length before normalization.
|
Vec2 |
normalizeLocal()
Normalizes and returns this vector.
|
Vec2 |
normalizeVec() |
void |
reset()
Resets the object for reuse.
|
Vec2 |
set(float x,
float y)
Set this vector component-wise.
|
Vec2 |
set(javafx.geometry.Point2D vector)
Set this vector to another vector.
|
Vec2 |
set(Vec2 v)
Set this vector to another vector.
|
Vec2 |
setFromAngle(double degrees)
Set this vector from angle.
|
void |
setZero()
Zero out this vector.
|
Vec2 |
skew()
Get the skew vector such that dot(skew_vec, other) == cross(vec, other).
|
void |
skew(Vec2 out)
Get the skew vector such that dot(skew_vec, other) == cross(vec, other);
does not alter this vector.
|
Vec2 |
sub(double otherX,
double otherY)
Return the difference of this vector and another; does not alter either one.
|
Vec2 |
sub(javafx.geometry.Point2D vector)
Return the difference of this vector and another; does not alter either one.
|
Vec2 |
sub(Vec2 v)
Return the difference of this vector and another; does not alter either one.
|
Vec2 |
subLocal(double x,
double y)
Subtract another vector from this one and return result - alters this vector.
|
Vec2 |
subLocal(Vec2 v)
Subtract another vector from this one and return result - alters this vector.
|
javafx.geometry.Point2D |
toPoint2D()
Note: object allocation.
|
String |
toString() |
public Vec2()
public Vec2(float x,
float y)
public Vec2(double x,
double y)
x - x componenty - y componentpublic Vec2(Vec2 toCopy)
public Vec2(javafx.geometry.Point2D toCopy)
public void setZero()
public Vec2 set(float x, float y)
x - x componenty - y componentpublic Vec2 set(javafx.geometry.Point2D vector)
public Vec2 setFromAngle(double degrees)
degrees - angle in degreespublic Vec2 add(Vec2 v)
public Vec2 add(javafx.geometry.Point2D vector)
public Vec2 add(double otherX, double otherY)
public Vec2 sub(Vec2 v)
public Vec2 sub(javafx.geometry.Point2D vector)
public Vec2 sub(double otherX, double otherY)
public Vec2 mul(double a)
public Vec2 negate()
public Vec2 negateLocal()
public Vec2 addLocal(Vec2 v)
public Vec2 addLocal(double x, double y)
public Vec2 subLocal(Vec2 v)
public Vec2 subLocal(double x, double y)
public Vec2 mulLocal(double a)
public Vec2 skew()
public void skew(Vec2 out)
out - the out vector to alterpublic float length()
public float lengthSquared()
public double distance(Vec2 other)
public double distance(javafx.geometry.Point2D other)
public double distance(double otherX,
double otherY)
public double distanceSquared(double otherX,
double otherY)
public boolean distanceLessThanOrEqual(double otherX,
double otherY,
double distance)
public boolean distanceGreaterThanOrEqual(double otherX,
double otherY,
double distance)
public Vec2 normalizeVec()
public float normalize()
public Vec2 normalizeLocal()
public Vec2 midpoint(javafx.geometry.Point2D other)
public boolean isValid()
public Vec2 abs()
public Vec2 absLocal()
public float angle()
public float angle(Vec2 other)
other - other vectorpublic float angle(javafx.geometry.Point2D other)
other - other vectorpublic float angle(double otherX,
double otherY)
otherX - x component of other vectorotherY - y component of other vectorpublic Vec2 copy()
public javafx.geometry.Point2D toPoint2D()
public void reset()
Poolablepublic static Vec2 fromAngle(double degrees)
public boolean equalsPoint2D(javafx.geometry.Point2D p)
p - Point2D representationCopyright © 2017. All rights reserved.