Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.eside.flingbox.math
Class Vector2D

    java.lang.Object
      edu.eside.flingbox.math.Vector2D

Direct Known Subclasses:
  GravitySource

    public class Vector2D

extends java.lang.Object

2D vector without application point. Also includes some basic operations with vectors.

Field Summary
`float` | `i` Vector components
`float` | `j` Vector components

Constructor Summary
`Vector2D()` Default constructor for an empty vector
`Vector2D(float i, float j)` Creates a new vector.
`Vector2D(Vector2D v)` Copy constructor

Method Summary
`Vector2D` | `add(Vector2D v)` Adds a vector
`float` | `angleWithVector(Vector2D v)` Computes angle formed by current vector and a given vector.
`float` | `crossProduct(Vector2D v)` Computes the Z axis of the cross product
`float` | `distanceToPoint(Vector2D p)` Calculates the distance to a given point
`float` | `dotProduct(Vector2D v)` Computes the dot product
`boolean` | `isAtSameSide(Vector2D v)` computes the side of vector
`float` | `length()` Computes the length of the vector
`Vector2D` | `mul(float s)` Multiplies by a scalar
`Vector2D` | `mul(Matrix22 m)` Multiplies current vector by a matrix
`static Vector2D` | `mul(Vector2D v, Matrix22 m)` Multiplies a vector by a matrix
`Vector2D` | `negate()` Negates current vector
`static Vector2D` | `negate(Vector2D v)` Negates current vector
`Vector2D` | `normalize()` Normalizes the vector
`Vector2D` | `normalVector()` Computes the vector's normal
`static Vector2D` | `normalVector(Vector2D v)` Computes the vector's normal
`float` | `projectOver(Vector2D v)` computes the length of projected vector
`Vector2D` | `set(float i, float j)` Sets vector's values
`Vector2D` | `set(Vector2D v)` Copies values from other vector
`Vector2D` | `sub(Vector2D v)` Subs a vector
`java.lang.String` | `toString()` Returns a string representing the vector

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### i

    public float i

  Vector components

### j

    public float j

  Vector components

Constructor Detail

### Vector2D

    public Vector2D()

  Default constructor for an empty vector

### Vector2D

    public Vector2D(float i,
                    float j)

  Creates a new vector.

  Parameters:
    `i` - X component
    `j` - Y component

### Vector2D

    public Vector2D(Vector2D v)

  Copy constructor

  Parameters:
    `v` - vector to copy

Method Detail

### set

    public Vector2D set(Vector2D v)

  Copies values from other vector

  Parameters:
    `v` - vector to be copied

### set

    public Vector2D set(float i,
                        float j)

  Sets vector's values

  Parameters:
    `i` - x component of the vector
    `j` - y component of the vector

### length

    public float length()

  Computes the length of the vector

  Returns:
    Length of vector

### negate

    public Vector2D negate()

  Negates current vector

### negate

    public static Vector2D negate(Vector2D v)

  Negates current vector

### add

    public Vector2D add(Vector2D v)

  Adds a vector

  Parameters:
    `v` - Vector
  Returns:
    result vector

### sub

    public Vector2D sub(Vector2D v)

  Subs a vector

  Parameters:
    `v` - Vector
  Returns:
    result vector

### mul

    public Vector2D mul(float s)

  Multiplies by a scalar

  Parameters:
    `s` - Scalar
  Returns:
    result vector

### dotProduct

    public float dotProduct(Vector2D v)

  Computes the dot product

  Parameters:
    `v` - vector
  Returns:
    dot product

### projectOver

    public float projectOver(Vector2D v)

  computes the length of projected vector

  Parameters:
    `v` - base vector
  Returns:
    length of projection

### isAtSameSide

    public boolean isAtSameSide(Vector2D v)

  computes the side of vector

  Parameters:
    `v` - vector to be compared
  Returns:
    true if two vectors angle is less than 90¼

### crossProduct

    public float crossProduct(Vector2D v)

  Computes the Z axis of the cross product

  Parameters:
    `v` - vector
  Returns:
    Z axis of cross product

### angleWithVector

    public float angleWithVector(Vector2D v)

  Computes angle formed by current vector and a given vector.

  Parameters:
    `v` - Vector
  Returns:
    angle formed [0..PI]

### mul

    public static Vector2D mul(Vector2D v,
                               Matrix22 m)

  Multiplies a vector by a matrix

  Parameters:
    `v` - Vector
    `m` - Matrix
  Returns:
    New vector with the result

### mul

    public Vector2D mul(Matrix22 m)

  Multiplies current vector by a matrix

  Parameters:
    `m` - Matrix
  Returns:
    New vector with the result

### normalize

    public Vector2D normalize()

  Normalizes the vector

  Returns:
    Normalized vector

### normalVector

    public Vector2D normalVector()

  Computes the vector's normal

  Returns:
    Vector with the normal.

### normalVector

    public static Vector2D normalVector(Vector2D v)

  Computes the vector's normal

  Returns:
    New vector with the normal.

### distanceToPoint

    public float distanceToPoint(Vector2D p)

  Calculates the distance to a given point

  Parameters:
    `p` - point
  Returns:
    distance

### toString

    public java.lang.String toString()

  Returns a string representing the vector

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD