public class Vector2
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
double[] |
data
Sequence of 3 coefficients.
|
Constructor and Description |
---|
Vector2()
New zero vector.
|
Vector2(double x,
double y)
New (
x ,y ) vector. |
Vector2(Point2 point)
New vector copy of
point . |
Vector2(Point2 from,
Point2 to) |
Vector2(Vector2 other)
New vector copy of
other . |
Modifier and Type | Method and Description |
---|---|
void |
add(Vector2 other)
Add each element of other to the corresponding element of this.
|
double |
at(int i)
i-th element.
|
java.lang.Object |
clone() |
void |
copy(Point2 point)
Make this a copy of
point . |
void |
copy(Vector2 other)
Make this a copy of other.
|
double |
dotProduct(double ox,
double oy) |
double |
dotProduct(Vector2 other)
Dot product of this and other.
|
boolean |
equals(java.lang.Object other)
Is this equal to other ?
|
void |
fill(double value)
Assign value to all elements.
|
int |
hashCode() |
boolean |
isZero()
Are all components to zero?.
|
double |
length()
Cartesian length.
|
void |
mult(Vector2 other)
Multiply each element of this by the corresponding element of other.
|
double |
normalize()
Transform this into an unit vector.
|
void |
scalarAdd(double value)
Add value to each element.
|
void |
scalarDiv(double value)
Divide each element by value.
|
void |
scalarMult(double value)
Multiply each element by value.
|
void |
scalarSub(double value)
Substract value to each element.
|
void |
set(double x,
double y)
Explicitly set the three components.
|
void |
set(int i,
double value)
Explicitly set the i-th component to value.
|
void |
sub(Vector2 other)
Subtract each element of other to the corresponding element of this.
|
java.lang.String |
toString() |
boolean |
validComponent(int i)
Is i the index of a component ?
|
double |
x() |
double |
y() |
public Vector2()
public Vector2(double x, double y)
x
,y
) vector.public Vector2(Vector2 other)
other
.public Vector2(Point2 point)
point
.public boolean isZero()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public boolean validComponent(int i)
public double at(int i)
public double x()
public double y()
public java.lang.Object clone()
clone
in class java.lang.Object
public double dotProduct(double ox, double oy)
public double dotProduct(Vector2 other)
public double length()
public void fill(double value)
public void set(int i, double value)
public void set(double x, double y)
public void add(Vector2 other)
public void sub(Vector2 other)
public void mult(Vector2 other)
public void scalarAdd(double value)
public void scalarSub(double value)
public void scalarMult(double value)
public void scalarDiv(double value)
public double normalize()
public void copy(Vector2 other)
public void copy(Point2 point)
point
.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object