public class GGVector
extends java.lang.Object
     (0, 0) o------------------>x-axis
            | .  / direction
            |  .
            |   .vector
            |    .
            |     .
            |      *
            v
          y-axis
 
 The direction of the vector is defined as the angle (0..2*pi) of the
 vector direction clockwise with reference to the x-coordinate direction.| Modifier and Type | Field and Description | 
|---|---|
double | 
x
The public x-coordinate. 
 | 
double | 
y
The public y-coordinate. 
 | 
| Constructor and Description | 
|---|
GGVector()
Constructs a zero vector (with coordinates (0, 0)). 
 | 
GGVector(double x,
        double y)
Constructs a vector from given double x-y-coordinates. 
 | 
GGVector(float x,
        float y)
Constructs a vector from given float x-y-coordinates. 
 | 
GGVector(int x,
        int y)
Constructs a vector from given integer x-y-coordinates. 
 | 
GGVector(android.graphics.Point pt)
Constructs a vector from integer coordinates using jawa.awt.Point. 
 | 
GGVector(PointD pt)
Constructs a vector from double coordinates using PointD. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
GGVector | 
add(GGVector v)
Returns a new vector that is the vector sum of the current vector and the given vector. 
 | 
GGVector | 
clone()
Returns a new vector with the same coordinates as the current vector. 
 | 
double | 
distanceTo(GGVector v)
Returns the distance between the current vector and the given vector. 
 | 
double | 
dot(GGVector v)
Returns the scalar product (dot product) of the current vector with the given vector. 
 | 
double | 
getDirection()
Returns the direction of the vector (range 0..2*pi) 
 | 
GGVector | 
getNormalized()
Returns a new vector with magnitude 1 in the direction of the given vector. 
 | 
GGVector | 
invert()
Returns a new vector with inverted coordinates. 
 | 
boolean | 
isEqual(GGVector v)
Returns true, if the current vector is identical to the given vector. 
 | 
boolean | 
isIntersecting(GGVector imageCenter,
              double imageDirection,
              android.graphics.Bitmap image,
              boolean isRotatable)
Returns true, if the current vector (casted to int values) points to a
 non-transparant pixel of the given image. 
 | 
double | 
magnitude()
Returns the magnitude (length) of the vector. 
 | 
double | 
magnitude2()
Returns the square of the magnitude, without squareroot calculation. 
 | 
GGVector | 
mult(double b)
Returns a new vector that is the product by a scalar of the current vector and the given double. 
 | 
GGVector | 
mult(float b)
Returns a new vector that is the product by a scalar of the current vector and the given float. 
 | 
GGVector | 
mult(int b)
Returns a new vector that is the product by a scalar of the current vector and the given integer. 
 | 
void | 
normalize()
Modifies the vector to unit magnitude. 
 | 
void | 
rotate(double angle)
Rotates the vector by the specified angle. 
 | 
GGVector | 
sub(GGVector v)
Returns a new vector that is the vector difference of the current vector and the given vector. 
 | 
java.lang.String | 
toString()
Returns a string with the x-y-coordinates in the format (x, y). 
 | 
public GGVector()
public GGVector(android.graphics.Point pt)
pt - the point that becomes a vectorpublic GGVector(PointD pt)
pt - the point that becomes a vectorpublic GGVector(int x,
        int y)
x - the x-coordinate of the vectory - the y-coordinate of the vectorpublic GGVector(float x,
        float y)
x - the x-coordinate of the vectory - the y-coordinate of the vectorpublic GGVector(double x,
        double y)
x - the x-coordinate of the vectory - the y-coordinate of the vectorpublic double magnitude()
public double magnitude2()
public void normalize()
public GGVector getNormalized()
public double getDirection()
public void rotate(double angle)
angle - the rotation angle (in radian, clockwise)public double dot(GGVector v)
v - the vector to take for the dot productpublic double distanceTo(GGVector v)
v - the vector to take for the distance measurementpublic GGVector add(GGVector v)
v - the vector to be added to the current vectorpublic GGVector invert()
public GGVector sub(GGVector v)
v - the vector to be substracted from the current vectorpublic GGVector mult(int b)
b - the integer scale factorpublic GGVector mult(float b)
b - the float scale factorpublic GGVector mult(double b)
b - the double scale factorpublic GGVector clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isIntersecting(GGVector imageCenter, double imageDirection, android.graphics.Bitmap image, boolean isRotatable)
imageCenter - the vector to the center of the imageimageDirection - the direction of the image (angle of edge ulx --> uly
 with respect to the positive x-direction (0..2*pi))isRotatable - if true, the imageDirection is considered; otherwise
 imageDirection = 0 is assumedpublic boolean isEqual(GGVector v)
v - the vector to compare