|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.cau.cs.kieler.core.math.KVector
public class KVector
A simple 2D vector class which supports translation, scaling, normalization etc.
Field Summary | |
---|---|
static double |
FULL_CIRCLE
one full turn in a circle in degrees (360°). |
double |
x
x coordinate. |
double |
y
y coordinate. |
Constructor Summary | |
---|---|
KVector()
Create vector with default coordinates (0,0). |
|
KVector(double alpha)
Creates a normalized vector for the passed angle in degree. |
|
KVector(double thex,
double they)
Constructs a new vector from given values. |
|
KVector(KVector v)
Creates an exact copy of a given vector v. |
Method Summary | |
---|---|
KVector |
add(KVector v)
Vector addition. |
static KVector |
add(KVector v1,
KVector v2)
Returns the sum of two given vectors as a new vector instance. |
KVector |
clone()
returns an exact copy of this vector. |
KVector |
differenceCreate(KVector v)
Create a sum from this vector and another vector. |
double |
distance(KVector v2)
Returns the distance between two vectors. |
static double |
distance(KVector v1,
KVector v2)
Returns the distance between two vectors. |
boolean |
equals(Object obj)
|
double |
getLength()
returns this vector's length. |
double |
getNorm()
Deprecated. use getLength() |
double |
getSquareLength()
returns square length of this vector. |
int |
hashCode()
|
KVector |
negate()
Negate the vector. |
KVector |
normalize()
Normalize the vector. |
KVector |
normalizedCreate()
Create a normalized version of this vector. |
void |
parse(String string)
Parse the given string and set the content of this data object. |
double |
productDot(KVector v2)
Returns the dot product of the two given vectors. |
static double |
productDot(KVector v1,
KVector v2)
Returns the dot product of the two given vectors. |
KVector |
reset()
Set vector to (0,0). |
KVector |
scale(double scale)
Scale the vector. |
KVector |
scaledCreate(double lambda)
Create a scaled version of this vector. |
KVector |
scaleToLength(double length)
scales this vector to the passed length. |
KVector |
sub(KVector v)
Vector subtraction. |
static KVector |
sub(KVector v1,
KVector v2)
Returns the subtraction of the two given vectors as a new vector instance. |
KVector |
sumCreate(KVector v)
Create a sum from this vector and another vector. |
double |
toDegrees()
Returns degree representation of this vector in degree. |
String |
toString()
|
void |
wiggle()
Add some "noise" to this vector. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public double x
public double y
public static final double FULL_CIRCLE
Constructor Detail |
---|
public KVector()
public KVector(double thex, double they)
thex
- x valuethey
- y valuepublic KVector(KVector v)
v
- existing vectorpublic KVector(double alpha)
alpha
- angle in [0, 360)Method Detail |
---|
public KVector clone()
clone
in class Object
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public final double getNorm()
public double getLength()
public double getSquareLength()
public final KVector reset()
this
public final KVector add(KVector v)
v
- vector to add
this + v
public static KVector add(KVector v1, KVector v2)
v1
- first vectorv2
- second vector
public final KVector sub(KVector v)
v
- vector to subtract
this
public static KVector sub(KVector v1, KVector v2)
v1
- first vectorv2
- second vector
public final KVector scale(double scale)
scale
- scaling factor
this
public KVector normalize()
this
public KVector scaleToLength(double length)
length
- length to scale to
this
public KVector negate()
this
public double toDegrees()
public final void wiggle()
public final KVector scaledCreate(double lambda)
lambda
- scaling factor
this
scaled by lambda
public final KVector normalizedCreate()
this
public final KVector sumCreate(KVector v)
v
- second addend
this
and v
public final KVector differenceCreate(KVector v)
v
- subtrahend
this
and v
public double distance(KVector v2)
v2
- second vector
public static double distance(KVector v1, KVector v2)
v1
- first vectorv2
- second vector
public double productDot(KVector v2)
v2
- second vector
public static double productDot(KVector v1, KVector v2)
v1
- first vectorv2
- second vector
public void parse(String string) throws KielerException
parse
in interface IDataObject
string
- a string
KielerException
- if the string does not have the expected format
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |