Class Vertex

java.lang.Object
   |
   +----Vertex

public class Vertex
extends Object
A class defining a vertex.


Constructor Index

 o Vertex()
Construct the vertex at (0, 0, 0).
 o Vertex(int, int, int)
Construct a vertex given a set of coordinates.

Method Index

 o bounds(Vertex, Vertex, Vertex)
Returns the pair of vertices that bound three collinear vertices.
 o collinear(Vertex, Vertex, Vertex)
Tests whether three vertices are collinear.
 o crossProduct(Vertex, Vertex)
Returns the cross product of two vectors
 o distanceSquared(Vertex, Vertex)
Returns the square of the distance between two vertices.
 o dotProduct(Vertex, Vertex)
Returns the dot product of two vectors
 o getCoords()
Get the coordinates of the vertex.
 o normSq()
Returns the square of the norm of a vector
 o sameVertex(Vertex, Vertex)
Tests whether two vertices are the same point.
 o toString()
Returns a string that describes a vertex.
 o vectorDiff(Vertex, Vertex)
Returns the vector difference between two vertices

Constructors

 o Vertex
 public Vertex()
Construct the vertex at (0, 0, 0).

 o Vertex
 public Vertex(int x,
               int y,
               int z)
Construct a vertex given a set of coordinates.

Parameters:
x, - y, z The coordinates.

Methods

 o getCoords
 public int[] getCoords()
Get the coordinates of the vertex.

Returns:
An array of three integers containing the coordinates (x, y, z).
 o 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.
 o 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
 o 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
 o 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
 o 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
 o dotProduct
 public static long dotProduct(Vertex v1,
                               Vertex v2)
Returns the dot product of two vectors

Parameters:
v1, - v2 the vectors
Returns:
v1.v2
 o vectorDiff
 public static Vertex vectorDiff(Vertex v1,
                                 Vertex v2)
Returns the vector difference between two vertices

Parameters:
v1, - v2 the vertices
Returns:
v1 - v2
 o 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
 o toString
 public String toString()
Returns a string that describes a vertex.

Overrides:
toString in class Object