|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectssmith.opengl.Vector3D
public class Vector3D
This class can represent a 3D vector. For instance a point in 3D space, or a relative position or movement. The class has methods to add, subtact, (cross and dot) multiply with other vectors. also many other methods.
| Field Summary | |
|---|---|
static boolean |
saveAsDouble
VRML only supports float but allow override if higher resolution required |
double |
x
x coordinate |
double |
y
y coordinate |
double |
z
z coordinate |
| Constructor Summary | |
|---|---|
Vector3D()
construct a vector with initial value zero. |
|
Vector3D(double x1,
double y1,
double z1)
a constructor to set initial values of x,y and z coodinates |
|
Vector3D(float x1,
float y1,
float z1)
a constructor to set initial values of x,y and z coodinates |
|
Vector3D(Vector3D in1)
copy constructor |
|
| Method Summary | |
|---|---|
void |
add(Vector3D other)
add other vector to this for theory see: http://www.euclideanspace.com/maths/algebra/vectors/index.htm |
static Vector3D |
add(Vector3D a,
Vector3D b)
static method to return sum of two vectors |
void |
bounds(Vector3D other,
int i)
use to combine bounds if i=0 take minimum otherwise maximum |
java.lang.Object |
clone()
overrides base clone method |
void |
copy(Vector3D other)
set the value of this instance to the value of other this can be used to reuse an instance without the overheads of garbidge collection |
void |
cross(Vector3D other)
cross product for theory see: http://www.euclideanspace.com/maths/algebra/vectors/index.htm |
double |
distanceSquared(Vector3D other)
return square of distance from end of this vector to end of other |
double |
dot(Vector3D other)
dot product for theory see: http://www.euclideanspace.com/maths/algebra/vectors/index.htm |
boolean |
equals(Vector3D other)
returns true if this vector has an equal value to other vector |
Vector3D |
getMinus()
return a vector pointing on the opposite direction to this without affecting the value of this instance |
double |
getx()
gets the value in the x dimension |
double |
gety()
gets the value in the y dimension |
double |
getz()
gets the value in the z dimension |
boolean |
greaterThan(Vector3D other)
returns true if any dimension of other vector is greater than the same dimension of this |
boolean |
lessThan(Vector3D other)
returns true if any dimension of other vector is less than the same dimension of this |
void |
minus()
inverts the direction of the vector |
void |
normalize()
convert this vector to unit length for theory see: http://www.euclideanspace.com/maths/algebra/vectors/normals/index.htm |
java.lang.String |
outstring(int format)
output as a string |
void |
scale(double sc)
scale this vector equally in all directions |
void |
scale(Vector3D other)
scale this vector posibly different in x,y and z directions |
void |
scaleInv(Vector3D other)
scale this vector by inverse of other |
void |
setX(double v)
set the x value only without althering the other dimentions |
void |
setY(double v)
set the y value only without althering the other dimentions |
void |
setZ(double v)
set the z value only without althering the other dimentions |
void |
sub(Vector3D other)
subtract other vector from this for theory see: http://www.euclideanspace.com/maths/algebra/vectors/index.htm |
static Vector3D |
sub(Vector3D a,
Vector3D b)
static method to return difference of two vectors |
java.lang.String |
toStatic()
return a string which represents the value which can be used in source code |
static java.lang.String |
vrmlType_s()
static method to give the VRML name of this vector |
java.lang.String |
vrmlType()
method to give the VRML name of this vector sometimes we cant use vrmlType_s because static methods cant be overriden |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean saveAsDouble
public double x
public double y
public double z
| Constructor Detail |
|---|
public Vector3D(double x1,
double y1,
double z1)
x1 - value of x coordinatey1 - value of y coordinatez1 - value of z coordinate
public Vector3D(float x1,
float y1,
float z1)
x1 - value of x coordinatey1 - value of y coordinatez1 - value of z coordinatepublic Vector3D(Vector3D in1)
in1 - set values to save value in1
returns a new instace with values the same as in1public Vector3D()
| Method Detail |
|---|
public static Vector3D add(Vector3D a,
Vector3D b)
a - first vector to be addedb - second vector to be added
public static Vector3D sub(Vector3D a,
Vector3D b)
a - first vectorb - subract this vector
public static java.lang.String vrmlType_s()
public java.lang.String vrmlType()
public java.lang.Object clone()
clone in class java.lang.Objectpublic void copy(Vector3D other)
other - instace we want to use value of, if null then set to zeropublic void sub(Vector3D other)
other - vector to be subtracted from thispublic void add(Vector3D other)
other - vector to be added to thispublic void minus()
public Vector3D getMinus()
public void normalize()
public void scale(double sc)
sc - scale factorpublic void scale(Vector3D other)
other - scale valuepublic void scaleInv(Vector3D other)
other - scale valuepublic double distanceSquared(Vector3D other)
other - calcules distance from this vector
public void cross(Vector3D other)
other - vector to take cross product withpublic double dot(Vector3D other)
other - vector to take dot product with
public void setX(double v)
v - new value for xpublic void setY(double v)
v - new value for ypublic void setZ(double v)
v - new value for zpublic double getx()
public double gety()
public double getz()
public java.lang.String toStatic()
public boolean greaterThan(Vector3D other)
other - vector to compare with this
public boolean lessThan(Vector3D other)
other - vector to compare with this
public boolean equals(Vector3D other)
other - vector to compare with this
public java.lang.String outstring(int format)
format">mode - values
0 - output modified values
1 - output original values
2 - output attribute
3 - output attribute in brackets
4 - output with f prefix
public void bounds(Vector3D other,
int i)
other">vector - to combine withi">if - i=0 take minimum otherwise maximum
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||