public class Vertex3D
extends java.lang.Object
Constructor and Description |
---|
Vertex3D(double[] a)
Converts an 3D double array to a Vertex3D object.
|
Vertex3D(double x,
double y,
double z)
Creates a new Vertex3D object.
|
Vertex3D(Vertex3D v)
Copy constuctor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Vertex3D v)
Elementwise addition of another vertex to this one.
|
double[] |
asArray() |
double |
distanceTo(Vertex3D v)
The distance between this vertex and another.
|
static boolean |
equalEps(double a,
double b)
Compares two doubles using absolute and relative
epsilon checking.
|
boolean |
equals(Vertex3D v)
Elemenwise comparison of equality between this vertex and another.
|
double |
length() |
Vertex3D |
midpoint(Vertex3D v)
Calculates the midpoint between this vertex and another.
|
void |
scaleToLength(double s)
Scales this vertex as a vector.
|
static double |
sqDistance(double[] a,
double[] b)
Calculates the squared Euclidean distance between two
vectors of arbitrary length.
|
double |
sqDistanceTo(Vertex3D v)
The squared distance from this vertex to another.
|
void |
sub(Vertex3D v)
Elementwise subtraction of another vertex from this one.
|
void |
times(double s)
Elementwise multiplication with a scalar.
|
java.lang.String |
toString() |
public Vertex3D(double x, double y, double z)
public Vertex3D(double[] a)
public Vertex3D(Vertex3D v)
public void add(Vertex3D v)
v
- other vertex.public void sub(Vertex3D v)
v
- other vertex.public void times(double s)
s
- the scalar value.public boolean equals(Vertex3D v)
v
- other vertex.public static boolean equalEps(double a, double b)
a
- double 'a'b
- double 'b'public Vertex3D midpoint(Vertex3D v)
v
- other vertex.public double sqDistanceTo(Vertex3D v)
v
- other vertex.public double distanceTo(Vertex3D v)
v
- other vertex.public static double sqDistance(double[] a, double[] b)
a
- vector ab
- vector bpublic double length()
public void scaleToLength(double s)
s
- the length to scale to.public double[] asArray()
public java.lang.String toString()
toString
in class java.lang.Object