cz.cuni.utils.math
Class M

java.lang.Object
  extended by cz.cuni.utils.math.M

public class M
extends java.lang.Object

This class contains many methods to deal with vertices / lines / planes / etc. in space. It has short name because it's expected to be used frequently.


Field Summary
static double DEG_TO_RAD
           
static long DOUBLE_TO_LONG
           
static double EPSILON
           
static int EPSILON_DIGITS
           
private static double LINE_INTERSECTION_EPSILON
           
private static double LINE_INTERSECTION_MIN_TO_COMPUTE_WITH
           
static double NEAR_ZERO
           
static int NEAR_ZERO_DIGITS
           
static double PROJECTION_EPSILON
          All M.project suffer a big precision error.
static double RAD_TO_DEG
           
static Tuple3DNormalizedComparator tuple3DNormalizedComparator
           
static Tuple3DNormalizedComparatorXYZ tuple3DNormalizedComparatorXYZ
           
static Tuple3DNormalizedComparatorYZ tuple3DNormalizedComparatorYZ
           
static Tuple3DNormalizedComparatorZ tuple3DNormalizedComparatorZ
           
static double UT_ANGLE_TO_RAD
           
 
Constructor Summary
M()
           
 
Method Summary
static double angle(Tuple2D a, Tuple2D b)
          Returns angle in rad.
static double angle(Tuple3D a, Tuple3D b)
           
static int clockwiseOrder2D(double x1, double y1, double x2, double y2, double x3, double y3)
          Three points in 2D ... assuming that [X2,Y2] is the right-most (biggest X coordinate) point of all points from polygon Edges exist as follows A1A2, A2A3 ...
static double coeficient(Line2D line, Tuple2D pointInLine, Tuple2D anotherPointInLine)
          'pointInLine' and 'anotherPointInLine' must lie on a 'line' anotherPointInLine = pointInLine + k * line.direction returns k
static java.lang.Object[] copyVertices2D(java.util.AbstractCollection vertices)
           
static java.lang.Object[] copyVertices3D(java.util.AbstractCollection vertices)
           
static java.lang.Object[] copyVertices4D(java.util.AbstractCollection vertices)
           
static double deg(double rad)
           
static double distance(Line3D line, Tuple3D point)
           
static double distance(Tuple2D a, Line2D l)
           
static double distance(Tuple2D a, Tuple2D b)
           
static double distance(Tuple3D a, Plane3D p)
           
static double distance(Tuple3D a, Tuple3D b)
           
static double distanceSigned(Tuple2D a, Line2D l)
           
static double distanceSigned(Tuple3D a, Plane3D p)
           
static long doubleToLong(double x)
           
static boolean equals(double x, double y)
           
static boolean equals(double x, double y, double precision)
           
static boolean equals(Plane3D a, Plane3D b)
           
static boolean equals(Plane3D a, Plane3D b, double precision)
           
static boolean equals(Tuple2D a, Tuple2D b)
           
static boolean equals(Tuple2D a, Tuple2D b, double precision)
           
static boolean equals(Tuple3D a, Tuple3D b)
           
static boolean equals(Tuple3D a, Tuple3D b, double precision)
           
static boolean equalsSafe(Tuple3D a, Tuple3D b)
           
static boolean equalsSafe(Tuple3D a, Tuple3D b, double precision)
           
static boolean inSegment(Segment2D s, Tuple2D point)
           
static boolean inSegment(Segment2D s, Tuple2D point, double precision)
           
static boolean inSegment(Segment3D s, Tuple3D point)
           
static boolean inSegment(Segment3D s, Tuple3D point, double precision)
           
static boolean inSegment(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Line2D segmentLine, Tuple2D point)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegment(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Line2D segmentLine, Tuple2D point, double precision)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegment(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Tuple2D point)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegment(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Tuple2D point, double precision)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegment(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Line3D segmentLine, Tuple3D point)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegment(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Line3D segmentLine, Tuple3D point, double precision)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegment(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Tuple3D point)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegment(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Tuple3D point, double precision)
          Retuns null == false, precise point in line which is created in evaluation.
static boolean inSegmentNotEnd(Segment2D s, Tuple2D point)
           
static boolean inSegmentNotEnd(Segment2D s, Tuple2D point, double precision)
           
static boolean inSegmentNotEnd(Segment3D s, Tuple3D point)
           
static boolean inSegmentNotEnd(Segment3D s, Tuple3D point, double precision)
           
static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Line2D segmentLine, Tuple2D point)
          e.g. inSegment but point !
static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Line2D segmentLine, Tuple2D point, double precision)
          e.g. inSegment but point !
static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Tuple2D point)
          e.g. inSegment but point !
static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment, Tuple2D secondEndOfSegment, Tuple2D point, double precision)
          e.g. inSegment but point !
static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Line3D segmentLine, Tuple3D point)
          e.g. inSegment but point !
static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Line3D segmentLine, Tuple3D point, double precision)
          e.g. inSegment but point !
static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Tuple3D point)
          e.g. inSegment but point !
static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment, Tuple3D secondEndOfSegment, Tuple3D point, double precision)
          e.g. inSegment but point !
static Tuple2D intersection(Line2D line1, Line2D line2)
           
static Tuple3D intersection(Line3D line1, Line3D line2)
          line1 == vector(nx, ny, nz), point(a, b, c) line2 == vector(mx, my, mz), point(u, v, w) Trying to solve problem for t, r from R: a + nx * t = u + mx * r b + ny * t = u + my * r c + nz * t = u + mz * r Robust implementation -> trying to compute with the biggest nA / mA
static Tuple3D intersection(Plane3D plane, Line3D line)
          Null if parallel or line completely in plane.
static Line3D intersection(Plane3D a, Plane3D b)
          From http://geometryalgorithms.com/Archive/algorithm_0104/algorithm_0104B.htm#intersect3D_2Planes()
static boolean intersectSegment(HalfLine2D line, Segment2D segment)
          True if line crosses the segment
static boolean intersectSegment(Line2D line, Segment2D segment)
          True if line crosses the segment
static boolean inTriangle(Tuple2D point, Triangle2D triangle)
           
static Tuple2D inverse(double x, double y)
           
static Tuple3D inverse(double x, double y, double z)
           
static Tuple2D inverse(Tuple2D a)
           
static Tuple3D inverse(Tuple3D a)
           
static boolean isCollinear(Tuple2D a, Tuple2D b, Tuple2D c)
           
static boolean isCollinear(Tuple2D a, Tuple2D b, Tuple2D c, double precision)
           
static boolean isCollinear(Tuple3D a, Tuple3D b, Tuple3D c)
           
static boolean isCollinear(Tuple3D a, Tuple3D b, Tuple3D c, double precision)
           
static boolean isTriangle(Tuple2D a, Tuple2D b, Tuple2D c)
           
static boolean isTriangle(Tuple3D a, Tuple3D b, Tuple3D c)
           
static double linearEq(double a, double b)
          aX + b = 0
static double linearEq(double a, double b, double c)
          aX + b = c
static double[] linearEq2(double a1, double b1, double c1, double a2, double b2, double c2)
          a1X + b1Y = c1
a2X + b2Y = c2
static void main(java.lang.String[] args)
           
static Tuple2D multi(double x, double y, double ratio)
           
static Tuple3D multi(double x, double y, double z, double ratio)
           
static Tuple2D multi(Tuple2D a, double ratio)
           
static Tuple3D multi(Tuple3D a, double ratio)
           
static Tuple3D multi(Tuple3D a, double x, double y, double z)
           
static Tuple3D multi(Tuple3D a, Tuple3D b)
           
static double multiScalar(Tuple2D a, Tuple2D b)
           
static double multiScalar(Tuple3D a, Tuple3D b)
           
static void normalizedAdaptiveSort(java.lang.Object[] array)
          Check wether some coords aren't almost the same...
static Tuple2D normalizedNormal(Tuple2D normal)
          Special kind of vector satisfying this constrain on (X, Y): vector is normalized and if (X !
static Tuple2D normalizedNormal(Tuple2D normal, double precision)
           
static Tuple3D normalizedNormal(Tuple3D normal)
          Special kind of vector satisfying this constrain on (X, Y, Z): vector is normalized and if (X !
static Tuple3D normalizedNormal(Tuple3D normal, double precision)
           
static Tuple3D normalizedNormalTestZero(Tuple3D normal)
           
static Tuple3D normalizedNormalTestZero(Tuple3D normal, double precision)
           
static Tuple2D[] normalizedOrder(Tuple2D a, Tuple2D b)
          Used to sort vertexes for hash codes.
static Tuple3D[] normalizedOrder(Tuple3D a, Tuple3D b)
          Used to sort vertexes for hash codes.
static Vertex2D[] normalizedOrder(Vertex2D a, Vertex2D b)
          Used to sort vertexes for hash codes.
static Vertex3D[] normalizedOrder(Vertex3D a, Vertex3D b)
          Used to sort vertexes for hash codes.
static Tuple3D outsideVector(Triangle3D t, Segment3D s)
          Segment must be formed of two triangles vertices!
static Tuple2D perpendicular(Tuple2D a)
           
static Tuple3D perpendicular2DYZ(Tuple3D v)
          Returns vector perpendicular to a vector projected into YZ plane.
static boolean planeIntersect(Plane3D a, Plane3D b)
           
static Tuple2D plus(double x, double y, double amount)
           
static Tuple3D plus(double x, double y, double z, double amount)
           
static Tuple2D plus(Tuple2D a, double amount)
           
static Tuple2D plus(Tuple2D a, Tuple2D b)
           
static Tuple3D plus(Tuple3D a, double amount)
           
static Tuple3D plus(Tuple3D a, Tuple3D b)
           
static Tuple3D project(Tuple3D point, Line3D line)
          Projects a point into a line 3D.
static Tuple3D project(Tuple3D pointInPlane, Line3D lineInPlane, Plane3D plane)
          Project 'pointInPlane' (which is in 'plane') to the 'lineInPlane' (which is also in 'plane').
static Tuple3D project(Tuple3D point, Plane3D plane)
          Project a point into a plane 3D.
static double[] quadraticEq(double a, double b, double c)
          aX^2 + bX + c = 0
static double rad(double deg)
           
static Tuple3D rotateX(double x, double y, double z, double rad)
           
static Tuple3D rotateX(Tuple3D a, double rad)
           
static Tuple3D rotateY(double x, double y, double z, double rad)
           
static Tuple3D rotateY(Tuple3D a, double rad)
           
static Tuple3D rotateYawPitchRoll(double x, double y, double z, double yawRad, double pitchRad, double rollRad)
           
static Tuple3D rotateYawPitchRoll(Tuple3D a, double yawRad, double pitchRad, double rollRad)
           
static Tuple3D rotateYawPitchRoll(Tuple3D a, Tuple3D yawPitchRollRad)
           
static Tuple3D rotateZ(double x, double y, double z, double rad)
           
static Tuple3D rotateZ(Tuple3D a, double rad)
           
static double round(double x, int precision)
           
static boolean sameSide(Tuple3D vertex1, Tuple3D vertex2, Plane3D plane)
           
static boolean sameSign(double x, double y)
          If y == 0 returns false, x == 0 && y > 0 -> false, x == 0 && y == 0 -> true
static boolean sameWay(Tuple2D vector1, Tuple2D vector2)
          CALL IFF vector1.equals(vector2) || vector1.equals(vector2.inverse())
static boolean sameWay(Tuple3D vector1, Tuple3D vector2)
          CALL IFF vector1.equals(vector2) || vector1.equals(vector2.inverse())
static double smallerAngle(double angle)
          Returns smaller angle in rad.
static double smallerAngle(Tuple2D a, Tuple2D b)
          Returns smaller angle in rad.
static double utAngleToRad(double utAngleDegree)
           
static Tuple2D vector(Tuple2D a, Tuple2D b)
           
static Tuple3D vector(Tuple3D a, Tuple3D b)
           
static boolean vectorEquals(Tuple2D a, Tuple2D b)
           
static boolean vectorEquals(Tuple2D a, Tuple2D b, double precision)
           
static boolean vectorEquals(Tuple3D a, Tuple3D b)
           
static boolean vectorEquals(Tuple3D a, Tuple3D b, double precision)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPSILON_DIGITS

public static final int EPSILON_DIGITS
See Also:
Constant Field Values

EPSILON

public static final double EPSILON

DOUBLE_TO_LONG

public static final long DOUBLE_TO_LONG

NEAR_ZERO_DIGITS

public static final int NEAR_ZERO_DIGITS
See Also:
Constant Field Values

NEAR_ZERO

public static final double NEAR_ZERO

PROJECTION_EPSILON

public static final double PROJECTION_EPSILON
All M.project suffer a big precision error.

See Also:
Constant Field Values

LINE_INTERSECTION_EPSILON

private static final double LINE_INTERSECTION_EPSILON
See Also:
Constant Field Values

LINE_INTERSECTION_MIN_TO_COMPUTE_WITH

private static final double LINE_INTERSECTION_MIN_TO_COMPUTE_WITH
See Also:
Constant Field Values

tuple3DNormalizedComparatorXYZ

public static final Tuple3DNormalizedComparatorXYZ tuple3DNormalizedComparatorXYZ

tuple3DNormalizedComparatorYZ

public static final Tuple3DNormalizedComparatorYZ tuple3DNormalizedComparatorYZ

tuple3DNormalizedComparatorZ

public static final Tuple3DNormalizedComparatorZ tuple3DNormalizedComparatorZ

tuple3DNormalizedComparator

public static final Tuple3DNormalizedComparator tuple3DNormalizedComparator

DEG_TO_RAD

public static final double DEG_TO_RAD
See Also:
Constant Field Values

RAD_TO_DEG

public static final double RAD_TO_DEG
See Also:
Constant Field Values

UT_ANGLE_TO_RAD

public static final double UT_ANGLE_TO_RAD
See Also:
Constant Field Values
Constructor Detail

M

public M()
Method Detail

rad

public static double rad(double deg)

deg

public static double deg(double rad)

utAngleToRad

public static double utAngleToRad(double utAngleDegree)

sameSign

public static boolean sameSign(double x,
                               double y)
If y == 0 returns false, x == 0 && y > 0 -> false, x == 0 && y == 0 -> true

Parameters:
x -
y -

copyVertices2D

public static java.lang.Object[] copyVertices2D(java.util.AbstractCollection vertices)

copyVertices3D

public static java.lang.Object[] copyVertices3D(java.util.AbstractCollection vertices)

copyVertices4D

public static java.lang.Object[] copyVertices4D(java.util.AbstractCollection vertices)

equals

public static boolean equals(double x,
                             double y)

equals

public static boolean equals(double x,
                             double y,
                             double precision)

round

public static double round(double x,
                           int precision)

doubleToLong

public static long doubleToLong(double x)

linearEq

public static double linearEq(double a,
                              double b)
aX + b = 0

Parameters:
a -
b -
Returns:
value of X

linearEq

public static double linearEq(double a,
                              double b,
                              double c)
aX + b = c

Parameters:
a -
b -
c -
Returns:
value of X

quadraticEq

public static double[] quadraticEq(double a,
                                   double b,
                                   double c)
aX^2 + bX + c = 0

Parameters:
a -
b -
c -
Returns:
values of X

linearEq2

public static double[] linearEq2(double a1,
                                 double b1,
                                 double c1,
                                 double a2,
                                 double b2,
                                 double c2)
a1X + b1Y = c1
a2X + b2Y = c2

Parameters:
a1 -
b1 -
c1 -
a2 -
b2 -
c2 -
Returns:
roots {x,y}

clockwiseOrder2D

public static int clockwiseOrder2D(double x1,
                                   double y1,
                                   double x2,
                                   double y2,
                                   double x3,
                                   double y3)
Three points in 2D ... assuming that [X2,Y2] is the right-most (biggest X coordinate) point of all points from polygon Edges exist as follows A1A2, A2A3 ... A1-----A2-----A3 can't be A1 == A2, A2 == A3 (but not detected, will return +1 / -1 for A1 == A3 will return 0) can't be A1.X > A2.X, A3.X > A2.X if A1 == A3 assuming clockwise order as +1

Parameters:
x1 - A1.X
y1 - A1.Y
x2 - A2.X
y2 - A2.Y
x3 - A3.X
y3 - A3.Y
Returns:
+1 or -1 according to wether the cw order is A2,A3 (+1) or A2,A1 (-1)

normalizedAdaptiveSort

public static void normalizedAdaptiveSort(java.lang.Object[] array)
Check wether some coords aren't almost the same...

Parameters:
array - must consists of Tuple3D instances (or descendants)

equals

public static boolean equals(Tuple2D a,
                             Tuple2D b)

equals

public static boolean equals(Tuple2D a,
                             Tuple2D b,
                             double precision)

vectorEquals

public static boolean vectorEquals(Tuple2D a,
                                   Tuple2D b)

vectorEquals

public static boolean vectorEquals(Tuple2D a,
                                   Tuple2D b,
                                   double precision)

vector

public static Tuple2D vector(Tuple2D a,
                             Tuple2D b)

distance

public static double distance(Tuple2D a,
                              Tuple2D b)

distance

public static double distance(Tuple2D a,
                              Line2D l)

distanceSigned

public static double distanceSigned(Tuple2D a,
                                    Line2D l)

inverse

public static Tuple2D inverse(double x,
                              double y)

inverse

public static Tuple2D inverse(Tuple2D a)

plus

public static Tuple2D plus(double x,
                           double y,
                           double amount)

plus

public static Tuple2D plus(Tuple2D a,
                           double amount)

plus

public static Tuple2D plus(Tuple2D a,
                           Tuple2D b)

multiScalar

public static double multiScalar(Tuple2D a,
                                 Tuple2D b)

multi

public static Tuple2D multi(double x,
                            double y,
                            double ratio)

multi

public static Tuple2D multi(Tuple2D a,
                            double ratio)

perpendicular

public static Tuple2D perpendicular(Tuple2D a)

sameWay

public static boolean sameWay(Tuple2D vector1,
                              Tuple2D vector2)
CALL IFF vector1.equals(vector2) || vector1.equals(vector2.inverse())

Parameters:
vector1 -
vector2 -
Returns:
wether vectors pointing the same way or opposite

angle

public static double angle(Tuple2D a,
                           Tuple2D b)
Returns angle in rad.

Parameters:
a -
b -

smallerAngle

public static double smallerAngle(double angle)
Returns smaller angle in rad. Doesn't have to be positive! angle should be within <-2PI, +2PI>


intersection

public static Tuple2D intersection(Line2D line1,
                                   Line2D line2)

coeficient

public static double coeficient(Line2D line,
                                Tuple2D pointInLine,
                                Tuple2D anotherPointInLine)
'pointInLine' and 'anotherPointInLine' must lie on a 'line' anotherPointInLine = pointInLine + k * line.direction returns k

Parameters:
line -
pointInLine -
anotherPointInLine -
Returns:
coeficient k from: anotherPointInLine = pointInLine + k * line.direction

smallerAngle

public static double smallerAngle(Tuple2D a,
                                  Tuple2D b)
Returns smaller angle in rad. Doesn't have to be positive!

Parameters:
a -
b -

normalizedOrder

public static Tuple2D[] normalizedOrder(Tuple2D a,
                                        Tuple2D b)
Used to sort vertexes for hash codes. null -> points are equal, otherwise returns [first, second] array of tuples a, b

Parameters:
a -
b -
Returns:
ordering {first, second}

normalizedOrder

public static Vertex2D[] normalizedOrder(Vertex2D a,
                                         Vertex2D b)
Used to sort vertexes for hash codes. null -> points are equal, otherwise returns [first, second] array of tuples a, b

Parameters:
a -
b -
Returns:
ordering {first, second}

normalizedNormal

public static Tuple2D normalizedNormal(Tuple2D normal)
Special kind of vector satisfying this constrain on (X, Y): vector is normalized and if (X != 0) X > 0, done if (X == 0) and (Y != 0) Y > 0, done X = Y = 0, done is used to test wether two planes are equal

Parameters:
normal -

normalizedNormal

public static Tuple2D normalizedNormal(Tuple2D normal,
                                       double precision)

intersectSegment

public static boolean intersectSegment(Line2D line,
                                       Segment2D segment)
True if line crosses the segment

Parameters:
line -
segment -

intersectSegment

public static boolean intersectSegment(HalfLine2D line,
                                       Segment2D segment)
True if line crosses the segment

Parameters:
line -
segment -

isTriangle

public static boolean isTriangle(Tuple2D a,
                                 Tuple2D b,
                                 Tuple2D c)

equals

public static boolean equals(Tuple3D a,
                             Tuple3D b)

equalsSafe

public static boolean equalsSafe(Tuple3D a,
                                 Tuple3D b)

equals

public static boolean equals(Tuple3D a,
                             Tuple3D b,
                             double precision)

equalsSafe

public static boolean equalsSafe(Tuple3D a,
                                 Tuple3D b,
                                 double precision)

sameWay

public static boolean sameWay(Tuple3D vector1,
                              Tuple3D vector2)
CALL IFF vector1.equals(vector2) || vector1.equals(vector2.inverse())

Parameters:
vector1 -
vector2 -
Returns:
wether vectors pointing the same way or opposite

normalizedNormal

public static Tuple3D normalizedNormal(Tuple3D normal)
Special kind of vector satisfying this constrain on (X, Y, Z): vector is normalized and if (X != 0) X > 0, done if (X == 0) and (Y != 0) Y > 0, done if (X == 0) and (Y == 0) and (Z != 0) Z > 0, done X = Y = Z = 0, done is used to test wether two planes are equal

Parameters:
normal -

normalizedNormal

public static Tuple3D normalizedNormal(Tuple3D normal,
                                       double precision)

normalizedNormalTestZero

public static Tuple3D normalizedNormalTestZero(Tuple3D normal)

normalizedNormalTestZero

public static Tuple3D normalizedNormalTestZero(Tuple3D normal,
                                               double precision)

equals

public static boolean equals(Plane3D a,
                             Plane3D b)

equals

public static boolean equals(Plane3D a,
                             Plane3D b,
                             double precision)

vectorEquals

public static boolean vectorEquals(Tuple3D a,
                                   Tuple3D b)

vectorEquals

public static boolean vectorEquals(Tuple3D a,
                                   Tuple3D b,
                                   double precision)

vector

public static Tuple3D vector(Tuple3D a,
                             Tuple3D b)

distance

public static double distance(Tuple3D a,
                              Tuple3D b)

distance

public static double distance(Tuple3D a,
                              Plane3D p)

distanceSigned

public static double distanceSigned(Tuple3D a,
                                    Plane3D p)

inverse

public static Tuple3D inverse(double x,
                              double y,
                              double z)

inverse

public static Tuple3D inverse(Tuple3D a)

plus

public static Tuple3D plus(double x,
                           double y,
                           double z,
                           double amount)

plus

public static Tuple3D plus(Tuple3D a,
                           double amount)

plus

public static Tuple3D plus(Tuple3D a,
                           Tuple3D b)

multiScalar

public static double multiScalar(Tuple3D a,
                                 Tuple3D b)

multi

public static Tuple3D multi(double x,
                            double y,
                            double z,
                            double ratio)

multi

public static Tuple3D multi(Tuple3D a,
                            double ratio)

multi

public static Tuple3D multi(Tuple3D a,
                            double x,
                            double y,
                            double z)

multi

public static Tuple3D multi(Tuple3D a,
                            Tuple3D b)

angle

public static double angle(Tuple3D a,
                           Tuple3D b)

perpendicular2DYZ

public static Tuple3D perpendicular2DYZ(Tuple3D v)
Returns vector perpendicular to a vector projected into YZ plane.

Parameters:
v -

rotateX

public static Tuple3D rotateX(double x,
                              double y,
                              double z,
                              double rad)

rotateX

public static Tuple3D rotateX(Tuple3D a,
                              double rad)

rotateY

public static Tuple3D rotateY(double x,
                              double y,
                              double z,
                              double rad)

rotateY

public static Tuple3D rotateY(Tuple3D a,
                              double rad)

rotateZ

public static Tuple3D rotateZ(double x,
                              double y,
                              double z,
                              double rad)

rotateZ

public static Tuple3D rotateZ(Tuple3D a,
                              double rad)

rotateYawPitchRoll

public static Tuple3D rotateYawPitchRoll(double x,
                                         double y,
                                         double z,
                                         double yawRad,
                                         double pitchRad,
                                         double rollRad)

rotateYawPitchRoll

public static Tuple3D rotateYawPitchRoll(Tuple3D a,
                                         double yawRad,
                                         double pitchRad,
                                         double rollRad)

rotateYawPitchRoll

public static Tuple3D rotateYawPitchRoll(Tuple3D a,
                                         Tuple3D yawPitchRollRad)

isCollinear

public static boolean isCollinear(Tuple2D a,
                                  Tuple2D b,
                                  Tuple2D c)

isCollinear

public static boolean isCollinear(Tuple2D a,
                                  Tuple2D b,
                                  Tuple2D c,
                                  double precision)

isCollinear

public static boolean isCollinear(Tuple3D a,
                                  Tuple3D b,
                                  Tuple3D c)

isCollinear

public static boolean isCollinear(Tuple3D a,
                                  Tuple3D b,
                                  Tuple3D c,
                                  double precision)

inSegment

public static boolean inSegment(Segment2D s,
                                Tuple2D point)

inSegment

public static boolean inSegment(Segment2D s,
                                Tuple2D point,
                                double precision)

inSegment

public static boolean inSegment(Tuple2D firstEndOfSegment,
                                Tuple2D secondEndOfSegment,
                                Tuple2D point)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
point -

inSegment

public static boolean inSegment(Tuple2D firstEndOfSegment,
                                Tuple2D secondEndOfSegment,
                                Tuple2D point,
                                double precision)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
point -
precision - ... used in equals()

inSegment

public static boolean inSegment(Tuple2D firstEndOfSegment,
                                Tuple2D secondEndOfSegment,
                                Line2D segmentLine,
                                Tuple2D point)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
segmentLine -
point -

inSegment

public static boolean inSegment(Tuple2D firstEndOfSegment,
                                Tuple2D secondEndOfSegment,
                                Line2D segmentLine,
                                Tuple2D point,
                                double precision)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
segmentLine -
point -
precision - ... used in equals()

inSegmentNotEnd

public static boolean inSegmentNotEnd(Segment2D s,
                                      Tuple2D point)

inSegmentNotEnd

public static boolean inSegmentNotEnd(Segment2D s,
                                      Tuple2D point,
                                      double precision)

inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment,
                                      Tuple2D secondEndOfSegment,
                                      Tuple2D point)
e.g. inSegment but point != first / second end of segment

Parameters:
firstEndOfSegment -
secondEndOfSegment -
point -

inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment,
                                      Tuple2D secondEndOfSegment,
                                      Tuple2D point,
                                      double precision)
e.g. inSegment but point != first / second end of segment


inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment,
                                      Tuple2D secondEndOfSegment,
                                      Line2D segmentLine,
                                      Tuple2D point)
e.g. inSegment but point != first / second end of segment


inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple2D firstEndOfSegment,
                                      Tuple2D secondEndOfSegment,
                                      Line2D segmentLine,
                                      Tuple2D point,
                                      double precision)
e.g. inSegment but point != first / second end of segment


inTriangle

public static boolean inTriangle(Tuple2D point,
                                 Triangle2D triangle)

inSegment

public static boolean inSegment(Segment3D s,
                                Tuple3D point)
Parameters:
s -
point -

inSegment

public static boolean inSegment(Segment3D s,
                                Tuple3D point,
                                double precision)

inSegment

public static boolean inSegment(Tuple3D firstEndOfSegment,
                                Tuple3D secondEndOfSegment,
                                Tuple3D point)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
point -

inSegment

public static boolean inSegment(Tuple3D firstEndOfSegment,
                                Tuple3D secondEndOfSegment,
                                Tuple3D point,
                                double precision)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
point -
precision - ... used in equals()

inSegment

public static boolean inSegment(Tuple3D firstEndOfSegment,
                                Tuple3D secondEndOfSegment,
                                Line3D segmentLine,
                                Tuple3D point)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
segmentLine -
point -

inSegment

public static boolean inSegment(Tuple3D firstEndOfSegment,
                                Tuple3D secondEndOfSegment,
                                Line3D segmentLine,
                                Tuple3D point,
                                double precision)
Retuns null == false, precise point in line which is created in evaluation.

Parameters:
firstEndOfSegment -
secondEndOfSegment -
segmentLine -
point -
precision - ... used in equals()

inSegmentNotEnd

public static boolean inSegmentNotEnd(Segment3D s,
                                      Tuple3D point)

inSegmentNotEnd

public static boolean inSegmentNotEnd(Segment3D s,
                                      Tuple3D point,
                                      double precision)

inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment,
                                      Tuple3D secondEndOfSegment,
                                      Tuple3D point)
e.g. inSegment but point != first / second end of segment

Parameters:
firstEndOfSegment -
secondEndOfSegment -
point -

inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment,
                                      Tuple3D secondEndOfSegment,
                                      Tuple3D point,
                                      double precision)
e.g. inSegment but point != first / second end of segment


inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment,
                                      Tuple3D secondEndOfSegment,
                                      Line3D segmentLine,
                                      Tuple3D point)
e.g. inSegment but point != first / second end of segment


inSegmentNotEnd

public static boolean inSegmentNotEnd(Tuple3D firstEndOfSegment,
                                      Tuple3D secondEndOfSegment,
                                      Line3D segmentLine,
                                      Tuple3D point,
                                      double precision)
e.g. inSegment but point != first / second end of segment


outsideVector

public static Tuple3D outsideVector(Triangle3D t,
                                    Segment3D s)
Segment must be formed of two triangles vertices! Returns vector which is in the plane of triangle, pointing outside the triangle from any point of the segment.

Parameters:
t -
s -

intersection

public static Tuple3D intersection(Line3D line1,
                                   Line3D line2)
line1 == vector(nx, ny, nz), point(a, b, c) line2 == vector(mx, my, mz), point(u, v, w) Trying to solve problem for t, r from R: a + nx * t = u + mx * r b + ny * t = u + my * r c + nz * t = u + mz * r Robust implementation -> trying to compute with the biggest nA / mA

Parameters:
line1 -
line2 -

isTriangle

public static boolean isTriangle(Tuple3D a,
                                 Tuple3D b,
                                 Tuple3D c)

planeIntersect

public static boolean planeIntersect(Plane3D a,
                                     Plane3D b)

intersection

public static Line3D intersection(Plane3D a,
                                  Plane3D b)
From http://geometryalgorithms.com/Archive/algorithm_0104/algorithm_0104B.htm#intersect3D_2Planes()

Parameters:
a -
b -
Returns:
line or null (parallel or the same)

project

public static Tuple3D project(Tuple3D point,
                              Line3D line)
Projects a point into a line 3D.

Parameters:
point -
line -

project

public static Tuple3D project(Tuple3D point,
                              Plane3D plane)
Project a point into a plane 3D.

Parameters:
point -
plane -
Returns:
projected point

project

public static Tuple3D project(Tuple3D pointInPlane,
                              Line3D lineInPlane,
                              Plane3D plane)
Project 'pointInPlane' (which is in 'plane') to the 'lineInPlane' (which is also in 'plane'). Doesn't check wether parametrs satisfy the assets.

Parameters:
pointInPlane -
plane -
lineInPlane -
Returns:
projected 'pointInPlane'

normalizedOrder

public static Tuple3D[] normalizedOrder(Tuple3D a,
                                        Tuple3D b)
Used to sort vertexes for hash codes. null -> points are equal, otherwise returns [first, second] array of tuples a, b

Parameters:
a -
b -

normalizedOrder

public static Vertex3D[] normalizedOrder(Vertex3D a,
                                         Vertex3D b)
Used to sort vertexes for hash codes. null -> points are equal, otherwise returns [first, second] array of tuples a, b

Parameters:
a -
b -

sameSide

public static boolean sameSide(Tuple3D vertex1,
                               Tuple3D vertex2,
                               Plane3D plane)

distance

public static double distance(Line3D line,
                              Tuple3D point)

intersection

public static Tuple3D intersection(Plane3D plane,
                                   Line3D line)
Null if parallel or line completely in plane.

Parameters:
plane -
line -

main

public static void main(java.lang.String[] args)