Class Vertex
java.lang.Object
|
+----Vertex
- public class Vertex
- extends Object
A class defining a vertex.
-
Vertex()
- Construct the vertex at (0, 0, 0).
-
Vertex(int, int, int)
- Construct a vertex given a set of coordinates.
-
bounds(Vertex, Vertex, Vertex)
- Returns the pair of vertices that bound three collinear vertices.
-
collinear(Vertex, Vertex, Vertex)
- Tests whether three vertices are collinear.
-
crossProduct(Vertex, Vertex)
- Returns the cross product of two vectors
-
distanceSquared(Vertex, Vertex)
-
Returns the square of the distance between two vertices.
-
dotProduct(Vertex, Vertex)
- Returns the dot product of two vectors
-
getCoords()
- Get the coordinates of the vertex.
-
normSq()
- Returns the square of the norm of a vector
-
sameVertex(Vertex, Vertex)
- Tests whether two vertices are the same point.
-
toString()
- Returns a string that describes a vertex.
-
vectorDiff(Vertex, Vertex)
- Returns the vector difference between two vertices
Vertex
public Vertex()
- Construct the vertex at (0, 0, 0).
Vertex
public Vertex(int x,
int y,
int z)
- Construct a vertex given a set of coordinates.
- Parameters:
- x, - y, z The coordinates.
getCoords
public int[] getCoords()
- Get the coordinates of the vertex.
- Returns:
- An array of three integers containing the coordinates (x, y, z).
sameVertex
public static boolean sameVertex(Vertex v1,
Vertex v2)
- Tests whether two vertices are the same point.
- Parameters:
- v1, - v2 the vertices to compare
- Returns:
- True/false if the vertices are the same/different.
collinear
public static boolean collinear(Vertex v1,
Vertex v2,
Vertex v3)
- Tests whether three vertices are collinear.
- Parameters:
- v1, - v2, v3 the vertices to test
- Returns:
- True/false if the vertices are collinear/non-collinear
bounds
public static Vertex[] bounds(Vertex v1,
Vertex v2,
Vertex v3)
- Returns the pair of vertices that bound three collinear vertices.
- Parameters:
- v1, - v2, v3 the vertices to test
- Returns:
- An array of two vertices that bound the tested vertices
distanceSquared
public static long distanceSquared(Vertex v1,
Vertex v2)
- Returns the square of the distance between two vertices.
- Parameters:
- v1, - v2 the vertices
- Returns:
- the distance squared between them
normSq
public long normSq()
- Returns the square of the norm of a vector
- Parameters:
- v - the vector
- Returns:
- the square of the norm of v
dotProduct
public static long dotProduct(Vertex v1,
Vertex v2)
- Returns the dot product of two vectors
- Parameters:
- v1, - v2 the vectors
- Returns:
- v1.v2
vectorDiff
public static Vertex vectorDiff(Vertex v1,
Vertex v2)
- Returns the vector difference between two vertices
- Parameters:
- v1, - v2 the vertices
- Returns:
- v1 - v2
crossProduct
public static Vertex crossProduct(Vertex v1,
Vertex v2)
- Returns the cross product of two vectors
- Parameters:
- v1, - v2 the vectors
- Returns:
- v1 x v2
toString
public String toString()
- Returns a string that describes a vertex.
- Overrides:
- toString in class Object