Package org.jbox2d.common
Class Vec2
java.lang.Object
org.jbox2d.common.Vec2
- All Implemented Interfaces:
Serializable
A 2D column vector.
- Author:
- Daniel Murphy
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Vec2abs()Return a new vector that has positive components.static Vec2final voidabsLocal()static voidfinal Vec2Return the sum of this vector and another; does not alter either one.final Vec2addLocal(float x, float y) Adds values to this vector and returns result - alters this vector.final Vec2Add another vector to this one and returns result - alters this vector.final Vec2clone()Return a copy of this vector.static Vec2static Vec2static floatstatic voidcrossToOut(float s, Vec2 a, Vec2 out) static voidcrossToOut(Vec2 a, float s, Vec2 out) static voidcrossToOutUnsafe(float s, Vec2 a, Vec2 out) static voidcrossToOutUnsafe(Vec2 a, float s, Vec2 out) static floatbooleaninthashCode()final booleanisValid()Does this vector contain finite coordinates?final floatlength()Get the length of this vector (the norm).final floatGet the length squared.static Vec2static voidstatic Vec2static voidfinal Vec2mul(float a) Return this vector multiplied by a scalar; does not alter this vector.final Vec2mulLocal(float a) Multiply this vector by a number and return result - alters this vector.final Vec2negate()Return the negation of this vector; does not alter this vector.final Vec2Flip the vector and return it - alters this vector.static voidnegateToOut(Vec2 a, Vec2 out) final floatConvert this vector into a unit vector.final Vec2set(float x, float y) Set the vector component-wise.final Vec2Set this vector to another vector.final voidsetZero()Zero out this vector.final Vec2skew()Get the skew vector such that dot(skew_vec, other) == cross(vec, other)final voidGet the skew vector such that dot(skew_vec, other) == cross(vec, other)final Vec2Return the difference of this vector and another; does not alter either one.final Vec2Subtract another vector from this one and return result - alters this vector.final StringtoString()
-
Field Details
-
x
public float x -
y
public float y
-
-
Constructor Details
-
Vec2
public Vec2()Default constructor does nothing (for performance). -
Vec2
public Vec2(float x, float y) Construct using coordinates. -
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()Get the length of this vector (the norm). Return the length of this vector. -
lengthSquared
public final float lengthSquared()Get the length squared. For performance, use this instead oflength(). Return the squared length of this vector. -
normalize
public final float normalize()Convert this vector into a unit vector. Returns the length. Normalize this vector and return the length before normalization. Alters this vector. -
isValid
public final boolean isValid()Does this vector contain finite coordinates? 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. -
toString
-
abs
-
absToOut
-
dot
-
cross
-
cross
-
crossToOut
-
crossToOutUnsafe
-
cross
-
crossToOut
-
crossToOutUnsafe
-
negateToOut
-
min
-
max
-
minToOut
-
maxToOut
-
hashCode
public int hashCode() -
equals
-