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.SerializableA 2D column vector- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDfloatxfloaty
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Vec2abs()Return a new vector that has positive components.static Vec2abs(Vec2 a)voidabsLocal()static voidabsToOut(Vec2 a, Vec2 out)Vec2add(Vec2 v)Return the sum of this vector and another; does not alter either one.Vec2addLocal(float x, float y)Adds values to this vector and returns result - alters this vector.Vec2addLocal(Vec2 v)Add another vector to this one and returns result - alters this vector.Vec2clone()Return a copy of this vector.static Vec2cross(float s, Vec2 a)static Vec2cross(Vec2 a, float s)static floatcross(Vec2 a, Vec2 b)static 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 floatdot(Vec2 a, Vec2 b)booleanequals(java.lang.Object obj)inthashCode()booleanisValid()True if the vector represents a pair of valid, non-infinite floating point numbers.floatlength()Return the length of this vector.floatlengthSquared()Return the squared length of this vector.static Vec2max(Vec2 a, Vec2 b)static voidmaxToOut(Vec2 a, Vec2 b, Vec2 out)static Vec2min(Vec2 a, Vec2 b)static voidminToOut(Vec2 a, Vec2 b, Vec2 out)Vec2mul(float a)Return this vector multiplied by a scalar; does not alter this vector.Vec2mulLocal(float a)Multiply this vector by a number and return result - alters this vector.Vec2negate()Return the negation of this vector; does not alter this vector.Vec2negateLocal()Flip the vector and return it - alters this vector.static voidnegateToOut(Vec2 a, Vec2 out)floatnormalize()Normalize this vector and return the length before normalization.Vec2set(float x, float y)Set the vector component-wise.Vec2set(Vec2 v)Set this vector to another vector.voidsetZero()Zero out this vector.Vec2skew()Get the skew vector such that dot(skew_vec, other) == cross(vec, other)voidskew(Vec2 out)Get the skew vector such that dot(skew_vec, other) == cross(vec, other)Vec2sub(Vec2 v)Return the difference of this vector and another; does not alter either one.Vec2subLocal(Vec2 v)Subtract another vector from this one and return result - alters this vector.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
x
public float x
-
y
public float y
-
-
Constructor Detail
-
Vec2
public Vec2()
-
Vec2
public Vec2(float x, float y)
-
Vec2
public Vec2(Vec2 toCopy)
-
-
Method Detail
-
setZero
public final void setZero()
Zero out this vector.
-
set
public final Vec2 set(float x, float y)
Set the vector component-wise.
-
add
public final Vec2 add(Vec2 v)
Return the sum of this vector and another; does not alter either one.
-
sub
public final Vec2 sub(Vec2 v)
Return the difference of this vector and another; does not alter either one.
-
mul
public final Vec2 mul(float a)
Return this vector multiplied by a scalar; does not alter this vector.
-
negate
public final Vec2 negate()
Return the negation of this vector; does not alter this vector.
-
negateLocal
public final Vec2 negateLocal()
Flip the vector and return it - alters this vector.
-
addLocal
public final Vec2 addLocal(Vec2 v)
Add another vector to this one and returns result - alters this vector.
-
addLocal
public final Vec2 addLocal(float x, float y)
Adds values to this vector and returns result - alters this vector.
-
subLocal
public final Vec2 subLocal(Vec2 v)
Subtract another vector from this one and return result - alters this vector.
-
mulLocal
public final Vec2 mulLocal(float a)
Multiply this vector by a number and return result - alters this vector.
-
skew
public final Vec2 skew()
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
-
skew
public final void skew(Vec2 out)
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
public final Vec2 abs()
Return a new vector that has positive components.
-
absLocal
public final void absLocal()
-
clone
public final Vec2 clone()
Return a copy of this vector.- Overrides:
clonein classjava.lang.Object
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(java.lang.Object)
-
-