Package org.graphstream.ui.geom
Class Vector2
java.lang.Object
org.graphstream.ui.geom.Vector2
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Vector3
public class Vector2 extends Object implements Serializable
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description double[]dataSequence of 3 coefficients. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidadd(Vector2 other)Add each element of other to the corresponding element of this.doubleat(int i)i-th element.Objectclone()voidcopy(Point2 point)Make this a copy ofpoint.voidcopy(Vector2 other)Make this a copy of other.doubledotProduct(double ox, double oy)doubledotProduct(Vector2 other)Dot product of this and other.booleanequals(Object other)Is this equal to other ?voidfill(double value)Assign value to all elements.inthashCode()booleanisZero()Are all components to zero?.doublelength()Cartesian length.voidmult(Vector2 other)Multiply each element of this by the corresponding element of other.doublenormalize()Transform this into an unit vector.voidscalarAdd(double value)Add value to each element.voidscalarDiv(double value)Divide each element by value.voidscalarMult(double value)Multiply each element by value.voidscalarSub(double value)Substract value to each element.voidset(double x, double y)Explicitly set the three components.voidset(int i, double value)Explicitly set the i-th component to value.voidsub(Vector2 other)Subtract each element of other to the corresponding element of this.StringtoString()booleanvalidComponent(int i)Is i the index of a component ?doublex()doubley()
-
Field Details
-
data
public double[] dataSequence of 3 coefficients.
-
-
Constructor Details
-
Method Details
-
isZero
public boolean isZero()Are all components to zero?. -
equals
Is this equal to other ? -
validComponent
public boolean validComponent(int i)Is i the index of a component ? In other words, is i >= 0 && < than #count() ? -
at
public double at(int i)i-th element. -
x
public double x() -
y
public double y() -
clone
-
dotProduct
public double dotProduct(double ox, double oy) -
dotProduct
Dot product of this and other. -
length
public double length()Cartesian length. -
fill
public void fill(double value)Assign value to all elements. -
set
public void set(int i, double value)Explicitly set the i-th component to value. -
set
public void set(double x, double y)Explicitly set the three components. -
add
Add each element of other to the corresponding element of this. -
sub
Subtract each element of other to the corresponding element of this. -
mult
Multiply each element of this by the corresponding element of other. -
scalarAdd
public void scalarAdd(double value)Add value to each element. -
scalarSub
public void scalarSub(double value)Substract value to each element. -
scalarMult
public void scalarMult(double value)Multiply each element by value. -
scalarDiv
public void scalarDiv(double value)Divide each element by value. -
normalize
public double normalize()Transform this into an unit vector.- Returns:
- the vector length.
-
copy
Make this a copy of other. -
copy
Make this a copy ofpoint. -
toString
-
hashCode
public int hashCode()
-