Package org.jbox2d.common
Class Vec2
java.lang.Object
org.jbox2d.common.Vec2
- All Implemented Interfaces:
java.io.Serializable
public class Vec2
extends java.lang.Object
implements java.io.Serializable
A 2D column vector
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Vec2
abs()
Return a new vector that has positive components.static final Vec2
final void
absLocal()
static final void
final Vec2
Return the sum of this vector and another; does not alter either one.final Vec2
addLocal
(float x, float y) Adds values to this vector and returns result - alters this vector.final Vec2
Add another vector to this one and returns result - alters this vector.final Vec2
clone()
Return a copy of this vector.static final Vec2
static final Vec2
static final float
static final void
crossToOut
(float s, Vec2 a, Vec2 out) static final void
crossToOut
(Vec2 a, float s, Vec2 out) static final void
crossToOutUnsafe
(float s, Vec2 a, Vec2 out) static final void
crossToOutUnsafe
(Vec2 a, float s, Vec2 out) static final float
boolean
equals
(java.lang.Object obj) int
hashCode()
final boolean
isValid()
True if the vector represents a pair of valid, non-infinite floating point numbers.final float
length()
Return the length of this vector.final float
Return the squared length of this vector.static final Vec2
static final void
static final Vec2
static final void
final Vec2
mul
(float a) Return this vector multiplied by a scalar; does not alter this vector.final Vec2
mulLocal
(float a) Multiply this vector by a number and return result - alters this vector.final Vec2
negate()
Return the negation of this vector; does not alter this vector.final Vec2
Flip the vector and return it - alters this vector.static final void
negateToOut
(Vec2 a, Vec2 out) final float
Normalize this vector and return the length before normalization.final Vec2
set
(float x, float y) Set the vector component-wise.final Vec2
Set this vector to another vector.final void
setZero()
Zero out this vector.final Vec2
skew()
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)final void
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)final Vec2
Return the difference of this vector and another; does not alter either one.final Vec2
Subtract another vector from this one and return result - alters this vector.final java.lang.String
toString()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
x
public float x -
y
public float y
-
-
Constructor Details
-
Vec2
public Vec2() -
Vec2
public Vec2(float x, float y) -
Vec2
-
-
Method Details
-
setZero
public final void setZero()Zero out this vector. -
set
Set the vector component-wise. -
set
Set this vector to another vector. -
add
Return the sum of this vector and another; does not alter either one. -
sub
Return the difference of this vector and another; does not alter either one. -
mul
Return this vector multiplied by a scalar; does not alter this vector. -
negate
Return the negation of this vector; does not alter this vector. -
negateLocal
Flip the vector and return it - alters this vector. -
addLocal
Add another vector to this one and returns result - alters this vector. -
addLocal
Adds values to this vector and returns result - alters this vector. -
subLocal
Subtract another vector from this one and return result - alters this vector. -
mulLocal
Multiply this vector by a number and return result - alters this vector. -
skew
Get the skew vector such that dot(skew_vec, other) == cross(vec, other) -
skew
Get the skew vector such that dot(skew_vec, other) == cross(vec, other) -
length
public final float length()Return the length of this vector. -
lengthSquared
public final float lengthSquared()Return the squared length of this vector. -
normalize
public final float normalize()Normalize this vector and return the length before normalization. Alters this vector. -
isValid
public final boolean isValid()True if the vector represents a pair of valid, non-infinite floating point numbers. -
abs
Return a new vector that has positive components. -
absLocal
public final void absLocal() -
clone
Return a copy of this vector.- Overrides:
clone
in classjava.lang.Object
-
toString
public final java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
abs
-
absToOut
-
dot
-
cross
-
cross
-
crossToOut
-
crossToOutUnsafe
-
cross
-
crossToOut
-
crossToOutUnsafe
-
negateToOut
-
min
-
max
-
minToOut
-
maxToOut
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
- See Also:
-
equals
public boolean equals(java.lang.Object obj) - Overrides:
equals
in classjava.lang.Object
- See Also:
-