|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectartofillusion.math.Vec2
public class Vec2
A Vec2 represents a 2 component vector.
Field Summary | |
---|---|
double |
x
|
double |
y
|
Constructor Summary | |
---|---|
Vec2()
Create a new Vec2 whose x and y components are equal to 0.0. |
|
Vec2(java.io.DataInputStream in)
Create a Vec2 by reading in information that was written by writeToFile(). |
|
Vec2(double xval,
double yval)
Create a new Vec2 with the specified x and y components. |
|
Vec2(Vec2 v)
Create a new Vec2 identical to another one. |
Method Summary | |
---|---|
void |
add(Vec2 v)
Add another Vec2 to this one. |
double |
cross(Vec2 v)
Calculate the cross product of this vector with another one. |
double |
distance(Vec2 v)
Calculate the Euclidean distance between this vector and another one. |
double |
distance2(Vec2 v)
Calculate the square of the Euclidean distance between this vector and another one. |
double |
dot(Vec2 v)
Calculate the dot product of this vector with another one. |
boolean |
equals(java.lang.Object o)
Determine whether two vectors are identical. |
int |
hashCode()
|
double |
length()
Calculate the length of this vector. |
double |
length2()
Calculate the square of the length of this vector. |
Vec2 |
minus(Vec2 v)
Calculate the difference between this vector and another one. |
void |
normalize()
Scale each component of this vector so that it has a length of 1. |
Vec2 |
plus(Vec2 v)
Calculate the sum of this vector and another one. |
void |
scale(double d)
Multiply each component of this vector by a constant. |
void |
set(double xval,
double yval)
Set the x and y components of this Vec2. |
void |
subtract(Vec2 v)
Subtract another Vec2 from this one. |
Vec2 |
times(double d)
Create a new Vec2 by multiplying each component of this one by a constant. |
java.lang.String |
toString()
|
static Vec2 |
vx()
Create a unit vector which points in the X direction. |
static Vec2 |
vy()
Create a unit vector which points in the Y direction. |
void |
writeToFile(java.io.DataOutputStream out)
Write out a serialized representation of this object. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public double x
public double y
Constructor Detail |
---|
public Vec2()
public Vec2(double xval, double yval)
public Vec2(Vec2 v)
public Vec2(java.io.DataInputStream in) throws java.io.IOException
java.io.IOException
Method Detail |
---|
public final void set(double xval, double yval)
public final double dot(Vec2 v)
public final double cross(Vec2 v)
public final Vec2 plus(Vec2 v)
public final Vec2 minus(Vec2 v)
public final Vec2 times(double d)
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public final double length()
public final double length2()
public final void add(Vec2 v)
public final void subtract(Vec2 v)
public final void scale(double d)
public final double distance(Vec2 v)
public final double distance2(Vec2 v)
public final void normalize()
public java.lang.String toString()
toString
in class java.lang.Object
public static Vec2 vx()
public static Vec2 vy()
public void writeToFile(java.io.DataOutputStream out) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |