com.badlogic.gdx.math
Interface Vector<T extends Vector<T>>

All Known Implementing Classes:
Vector2, Vector3

public interface Vector<T extends Vector<T>>

Encapsulates a general vector. Allows chaining operations by returning a reference to itself in all modification methods. See Vector2 and Vector3 for specific implementations.

Author:
Xoppa

Method Summary
 T add(T v)
          Adds the given vector to this vector
 T clamp(float min, float max)
          Clamps this vector's length to given value
 T cpy()
           
 float dot(T v)
           
 float dst(T v)
           
 float dst2(T v)
          This is much faster to calculate than dst(Vector) It avoids a calculating square root, so it is mostly useful for comparisons
 float len()
           
 float len2()
           
 T lerp(T target, float alpha)
          Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1].
 T limit(float limit)
          Limits this vector's length to given value
 T nor()
          Normalizes this vector.
 T scl(float scalar)
          Scales this vector by a scalar
 T scl(T v)
          Scales this vector by another vector
 T set(T v)
          Sets this vector from the given vector
 T sub(T v)
          Substracts the given vector from this vector.
 

Method Detail

cpy

T cpy()
Returns:
a copy of this vector

len

float len()
Returns:
The euclidian length

len2

float len2()
Returns:
The squared euclidian length

limit

T limit(float limit)
Limits this vector's length to given value

Returns:
This vector for chaining

clamp

T clamp(float min,
        float max)
Clamps this vector's length to given value

Parameters:
min - Min length
max - Max length
Returns:
This vector for chaining

set

T set(T v)
Sets this vector from the given vector

Parameters:
v - The vector
Returns:
This vector for chaining

sub

T sub(T v)
Substracts the given vector from this vector.

Parameters:
v - The vector
Returns:
This vector for chaining

nor

T nor()
Normalizes this vector. Does nothing if it is zero.

Returns:
This vector for chaining

add

T add(T v)
Adds the given vector to this vector

Parameters:
v - The vector
Returns:
This vector for chaining

dot

float dot(T v)
Parameters:
v - The other vector
Returns:
The dot product between this and the other vector

scl

T scl(float scalar)
Scales this vector by a scalar

Parameters:
scalar - The scalar
Returns:
This vector for chaining

scl

T scl(T v)
Scales this vector by another vector

Returns:
This vector for chaining

dst

float dst(T v)
Parameters:
v - The other vector
Returns:
the distance between this and the other vector

dst2

float dst2(T v)
This is much faster to calculate than dst(Vector) It avoids a calculating square root, so it is mostly useful for comparisons

Parameters:
v - The other vector
Returns:
the squared distance between this and the other vector

lerp

T lerp(T target,
       float alpha)
Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector.

Parameters:
target - The target vector
alpha - The interpolation coefficient
Returns:
This vector for chaining.


Copyright © 2013. All Rights Reserved.