lt.monarch.chart.chart3D.engine.vecmath
Class GeomMath

java.lang.Object
  extended by lt.monarch.chart.chart3D.engine.vecmath.GeomMath

public final class GeomMath
extends java.lang.Object

A class to contain general or more specific mathematics functions.


Field Summary
Modifier and Type Field and Description
static double epsilon
          Small value
 
Method Summary
Modifier and Type Method and Description
static boolean aboutEqual(double a, double b)
          Determines whether two specified values are about to be equal under some tolerance.
static int clampByte(int val)
          Clamp integer to byte values
static boolean doLinesIntersect2D(Vector3d a1, Vector3d a2, Vector3d b1, Vector3d b2)
          Determines whether projected into view port plane line segments do intersects or not.
static boolean inRangeIncluded(double r1, double r2, double value)
          Determines whether the specified value is in range.
static double lineEquation2D(Vector3d lp1, Vector3d lp2, Vector3d P)
          Calculates a distance from a point to the given line.
static boolean linesAreParallel2D(Vector3d a_lp1, Vector3d a_lp2, Vector3d b_lp1, Vector3d b_lp2)
          Determines whether two projected into view port plane lines are parallel or not.
static double planeEquation(Vector3d RP, Vector3d N, Vector3d P)
          Retrieves the distance from the plane of the given point.
static boolean pointInTriangle2D(Vector3d tp1, Vector3d tp2, Vector3d tp3, Vector3d P)
          Determines whether the specified point is on the projected into view port plane triangle area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

epsilon

public static double epsilon
Small value

Method Detail

planeEquation

public static double planeEquation(Vector3d RP,
                                   Vector3d N,
                                   Vector3d P)
Retrieves the distance from the plane of the given point.

Parameters:
RP - a reference point of a plane
N - a normal of a plane
P - a point which distance will be calculated
Returns:
the distance of the given point to the plane

pointInTriangle2D

public static boolean pointInTriangle2D(Vector3d tp1,
                                        Vector3d tp2,
                                        Vector3d tp3,
                                        Vector3d P)
Determines whether the specified point is on the projected into view port plane triangle area.

Parameters:
tp1 - the first triangle vertex position
tp2 - the second triangle vertex position
tp3 - the third triangle vertex position
P - the point to be checked position
Returns:
true if the specified point projection is on projected triangle area

doLinesIntersect2D

public static boolean doLinesIntersect2D(Vector3d a1,
                                         Vector3d a2,
                                         Vector3d b1,
                                         Vector3d b2)
Determines whether projected into view port plane line segments do intersects or not.

Parameters:
a1 - the first line segment start position
a2 - the first line segment end position
b1 - the second line start position
b2 - the second line end position
Returns:
true if line segments intersects

linesAreParallel2D

public static boolean linesAreParallel2D(Vector3d a_lp1,
                                         Vector3d a_lp2,
                                         Vector3d b_lp1,
                                         Vector3d b_lp2)
Determines whether two projected into view port plane lines are parallel or not.

Parameters:
a_lp1 - the first line start position
a_lp2 - the first line end position
b_lp1 - the second line start position
b_lp2 - the second line end position
Returns:
true if lines are parallel

lineEquation2D

public static double lineEquation2D(Vector3d lp1,
                                    Vector3d lp2,
                                    Vector3d P)
Calculates a distance from a point to the given line. Note that positions are projected into view port plane.

Parameters:
lp1 - the first line end point position
lp2 - the second line end point position
P - the point to be checked
Returns:
the signed distance from the line

inRangeIncluded

public static boolean inRangeIncluded(double r1,
                                      double r2,
                                      double value)
Determines whether the specified value is in range.

Parameters:
r1 - the range starting position
r2 - the range ending position
value - the value to check
Returns:
true if the value is in range

aboutEqual

public static boolean aboutEqual(double a,
                                 double b)
Determines whether two specified values are about to be equal under some tolerance.

Parameters:
a - the first value
b - the second value
Returns:
true if the values are about equal

clampByte

public static int clampByte(int val)
Clamp integer to byte values

Parameters:
val - value to clamp.
Returns:
value clamped to byte values