de.jreality.math
Class P2

java.lang.Object
  extended by de.jreality.math.P2

public final class P2
extends java.lang.Object

Static methods for geometry of the real projective plane RP2. Rn for method conventions and discussion of the ubiquitous metricnature parameter. Pn for other methods applicable in n-dimensional projective space.

Author:
Charles Gunn

Method Summary
static double[][] chopConvexPolygonWithLine(double[][] polygon, double[] line)
          The assumption is that the line is specified in such a way that vertices to be cut away have a negative inner product with the line coordinates.
static int getFirstOutsideEdge(double[][] polygon, boolean[] open, double[] point)
           
static double[] imbedMatrixP2InP3(double[] dst, double[] m3)
           
static double[] imbedP2InP3(double[] vec4, double[] vec3)
          Convert (x,y,z) into (x,y,0,z)
static boolean isConvex(double[][] polygon)
          Returns true if and only if the polygon described by the point series polygon is convex.
static double[] lineFromPoints(double[] line, double[] p1, double[] p2)
          Calculate the line coordinates of the line connecting the two points p1 and p2.
static double[] makeDirectIsometryFromFrame(double[] dst, double[] point, double[] xdir, int metric)
          Generate a direct isometry which maps the frame F determined by point and xdir to the standard frame represented by the identity matrix.
static double[] makeDirectIsometryFromFrames(double[] dst, double[] p0, double[] p1, double[] q0, double[] q1, int signature)
          Generate a direct isometry that carries the frame determined by p0 and p1 to that determined by q0 and q1.
static double[] normalizeLine(double[] dst, double[] src)
           
static double[] perpendicularBisector(double[] dst, double[] p1, double[] p2, int metric)
          Calculate the perpendicular bisector of the segment p1 and p2 with metricnature metricnature
static double[] pointFromLines(double[] point, double[] l1, double[] l2)
          Calculate the homogeneous coordinates of the point of intersection of the two lines l1 and l2.
static boolean polygonContainsPoint(double[][] polygon, boolean[] open, double[] point)
           
static boolean polygonContainsPoint(double[][] polygon, double[] point)
          Returns true if and only if point is within the polygon determined by the points contained in the array polygon.
static double[] projectP3ToP2(double[] vec3, double[] vec4)
          Convert the input (x,y,z,w) into (x,y,w).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

perpendicularBisector

public static double[] perpendicularBisector(double[] dst,
                                             double[] p1,
                                             double[] p2,
                                             int metric)
Calculate the perpendicular bisector of the segment p1 and p2 with metricnature metricnature

Parameters:
dst -
p1 -
p2 -
metric -
Returns:

pointFromLines

public static double[] pointFromLines(double[] point,
                                      double[] l1,
                                      double[] l2)
Calculate the homogeneous coordinates of the point of intersection of the two lines l1 and l2.

Parameters:
point -
l1 -
l2 -
Returns:

lineFromPoints

public static double[] lineFromPoints(double[] line,
                                      double[] p1,
                                      double[] p2)
Calculate the line coordinates of the line connecting the two points p1 and p2.

Parameters:
point -
l1 -
l2 -
Returns:

normalizeLine

public static double[] normalizeLine(double[] dst,
                                     double[] src)

polygonContainsPoint

public static boolean polygonContainsPoint(double[][] polygon,
                                           double[] point)
Returns true if and only if point is within the polygon determined by the points contained in the array polygon.

Parameters:
polygon -
point -
Returns:

polygonContainsPoint

public static boolean polygonContainsPoint(double[][] polygon,
                                           boolean[] open,
                                           double[] point)

getFirstOutsideEdge

public static int getFirstOutsideEdge(double[][] polygon,
                                      boolean[] open,
                                      double[] point)

isConvex

public static boolean isConvex(double[][] polygon)
Returns true if and only if the polygon described by the point series polygon is convex.

Parameters:
polygon -
Returns:

chopConvexPolygonWithLine

public static double[][] chopConvexPolygonWithLine(double[][] polygon,
                                                   double[] line)
The assumption is that the line is specified in such a way that vertices to be cut away have a negative inner product with the line coordinates. The result is a new point array that defines the polygon obtained by cutting off all points with negative inner product with the given line. The polygon is assumed to be convex.

Parameters:
polygon -
line -
Returns:

makeDirectIsometryFromFrames

public static double[] makeDirectIsometryFromFrames(double[] dst,
                                                    double[] p0,
                                                    double[] p1,
                                                    double[] q0,
                                                    double[] q1,
                                                    int signature)
Generate a direct isometry that carries the frame determined by p0 and p1 to that determined by q0 and q1. See makeDirectIsometryFromFrame(double[], double[], double[], int).

Parameters:
dst -
p0 -
p1 -
q0 -
q1 -
signature -
Returns:

makeDirectIsometryFromFrame

public static double[] makeDirectIsometryFromFrame(double[] dst,
                                                   double[] point,
                                                   double[] xdir,
                                                   int metric)
Generate a direct isometry which maps the frame F determined by point and xdir to the standard frame represented by the identity matrix. F is the frame based at point whose whose tangent space is spanned by a unit tangent vector in the direction of xdir, and a second tangent vector orthogonal to both point and xdir.

Parameters:
dst -
point -
xdir -
metric -
Returns:

projectP3ToP2

public static double[] projectP3ToP2(double[] vec3,
                                     double[] vec4)
Convert the input (x,y,z,w) into (x,y,w).

Parameters:
vec3 -
vec4 -
Returns:

imbedP2InP3

public static double[] imbedP2InP3(double[] vec4,
                                   double[] vec3)
Convert (x,y,z) into (x,y,0,z)

Parameters:
vec4 -
vec3 -
Returns:

imbedMatrixP2InP3

public static double[] imbedMatrixP2InP3(double[] dst,
                                         double[] m3)