Class Point

java.lang.Object
  extended by Point
Direct Known Subclasses:
Vertex

public class Point
extends java.lang.Object

An n-dimensional geometric point, with convenience methods for those who prefer to live in 2-, 3-, or 4-D space and several static methods dealing with small numbers of Points (in 2D, plus 1 method for 3D). Names for some of these methods come from: O'Rourke, _Computational Geometry in C_


Constructor Summary
Point(double[] v)
          Constructor for an nD point.
Point(double x, double y)
          Constructor for a 2D Point.
Point(double x, double y, double z)
          Constructor for a 3D Point.
Point(double x, double y, double z, double w)
          Constructor for a 4D Point.
 
Method Summary
static double area2(Point a, Point b, Point c)
          Twice the signed area of the (2D) triangle abc.
 boolean between(Point a, Point b)
          Is this (2D) Point on the interior of the line segment ab.
 boolean collinear(Point a, Point b)
          Is this (2D) Point on the line determined by a and b.
 boolean collinear3(Point a, Point b)
          Is this (3D) Point on the line determined by a and b
 double coord(int c)
          An individual coordinate.
 int dimension()
          The dimension.
 double distanceL1(Point a)
          The distance to another point using the L1 norm.
 double distanceL2(Point a)
          The distance to another point using the L2 norm.
 double distanceL2squared(Point a)
          The distance to another point using the L2 norm squared.
static boolean intersect(Point a, Point b, Point c, Point d)
          Does the (2D) line segment ab intersect cd (grazing intersections are allowed).
static boolean intersectProp(Point a, Point b, Point c, Point d)
          Does the (2D) line segment ab properly intersect line segment cd.
 boolean left(Point a, Point b)
          Is this (2D) Point strictly to the left of the oriented line determined by a and b.
 boolean leftOn(Point a, Point b)
          Is this (2D) Point to the left or on the oriented line determined by a and b.
 java.lang.String toString()
          Format the point.
 java.lang.String toString(java.lang.String df)
          Format the point using a hint.
static double volume6(Point a, Point b, Point c, Point d)
          Six times the signed volume of the (3D) tetrahedron abcd.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point

public Point(double x,
             double y)
Constructor for a 2D Point.

Parameters:
x - the x-coordinate
y - the y-coordinate

Point

public Point(double x,
             double y,
             double z)
Constructor for a 3D Point.

Parameters:
x - the x-coordinate
y - the y-coordinate
z - the z-coordinate

Point

public Point(double x,
             double y,
             double z,
             double w)
Constructor for a 4D Point.

Parameters:
x - the x-coordinate
y - the y-coordinate
z - the z-coordinate
w - the z-coordinate

Point

public Point(double[] v)
Constructor for an nD point.

Parameters:
v - coordinates
Method Detail

toString

public java.lang.String toString(java.lang.String df)
Format the point using a hint.

Parameters:
df - the format to be used for a single coordinate

toString

public java.lang.String toString()
Format the point.

Overrides:
toString in class java.lang.Object

distanceL1

public double distanceL1(Point a)
The distance to another point using the L1 norm.

Parameters:
a - the other point

distanceL2

public double distanceL2(Point a)
The distance to another point using the L2 norm.

Parameters:
a - the other point

distanceL2squared

public double distanceL2squared(Point a)
The distance to another point using the L2 norm squared.

Parameters:
a - the other point

coord

public double coord(int c)
An individual coordinate.

Parameters:
c - the index of the desired coordinate

dimension

public int dimension()
The dimension.


left

public boolean left(Point a,
                    Point b)
Is this (2D) Point strictly to the left of the oriented line determined by a and b.

Parameters:
a - the first point on the line
b - the second point on the line

leftOn

public boolean leftOn(Point a,
                      Point b)
Is this (2D) Point to the left or on the oriented line determined by a and b.

Parameters:
a - the first point on the line
b - the second point on the line

collinear

public boolean collinear(Point a,
                         Point b)
Is this (2D) Point on the line determined by a and b.

Parameters:
a - the first point on the line
b - the second point on the line

collinear3

public boolean collinear3(Point a,
                          Point b)
Is this (3D) Point on the line determined by a and b

Parameters:
a - the first point on the line
b - the second point on the line

between

public boolean between(Point a,
                       Point b)
Is this (2D) Point on the interior of the line segment ab.

Parameters:
a - the first point of the line segment.
b - the second of the line segment.

area2

public static double area2(Point a,
                           Point b,
                           Point c)
Twice the signed area of the (2D) triangle abc.

Parameters:
a - the first point
b - the second point
c - the third point

volume6

public static double volume6(Point a,
                             Point b,
                             Point c,
                             Point d)
Six times the signed volume of the (3D) tetrahedron abcd.

Parameters:
a - the first point
b - the second point
c - the third point
d - the fourth point

intersectProp

public static boolean intersectProp(Point a,
                                    Point b,
                                    Point c,
                                    Point d)
Does the (2D) line segment ab properly intersect line segment cd.

Parameters:
a - the first point on the first line segment
b - the second point on the first line segment
c - the first point on the second line segment
d - the second point on the second line segment

intersect

public static boolean intersect(Point a,
                                Point b,
                                Point c,
                                Point d)
Does the (2D) line segment ab intersect cd (grazing intersections are allowed).

Parameters:
a - the first point on the first line segment
b - the second point on the first line segment
c - the first point on the second line segment
d - the second point on the second line segment