com.kuka.math.geometry
Class MathUtils

java.lang.Object
  extended by com.kuka.math.geometry.MathUtils

public final class MathUtils
extends Object

Utility class providing static helper methods for the mathematical classes.

See Also:
Vector3D, Matrix

Method Summary
static IRotation defensiveCopy(IRotation orig)
          Returns an immutable AbstractRotation instance of the given rotation.
static ITransformation defensiveCopy(ITransformation orig)
          Returns an immutable AbstractTransformation instance of the given transformation.
static boolean elementEqual(IRotation a, IRotation b, double epsilon)
          Checks if two Rotations are approximately equal by checking the matrix representations for element-wise approximate equality.
static boolean elementEqual(ITransformation a, ITransformation b, double epsilon)
          Checks if two transformations are approximately equal.
static boolean elementEqual(Matrix a, Matrix b, double epsilon)
          Checks if the two matrices are element wise nearly equal.
static boolean elementEqual(Point3D a, Point3D b, double epsilon)
          Checks if the two points are element wise nearly equal.
static boolean elementEqual(Vector3D a, Vector3D b, double epsilon)
          Checks if the two vectors are element wise nearly equal.
static boolean equal(double value1, double value2, double epsilon)
          Checks if the two double values are nearly equal.
static Vector3D getAxisVector(CoordinateAxis axis)
          Returns an unit vector representing the specified CoordinateAxis.
static NumberFormat getDefaultNumberFormat()
          Returns an instance of the default NumberFormat.
static Vector3D getDirectionVector(CoordinateDirection direction)
          Returns an unit vector representing the specified CoordinateDirection.
static Vector3D getNormalVector(CoordinatePlane plane)
          Returns the normal vector corresponding to the specified CoordinatePlane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equal

public static boolean equal(double value1,
                            double value2,
                            double epsilon)
Checks if the two double values are nearly equal. A small epsilon check is performed.

Parameters:
value1 - The first value.
value2 - The second value.
epsilon - the maximum tolerated difference between the values
Returns:
True if |value1 - value2| < epsilon.

elementEqual

public static boolean elementEqual(Vector3D a,
                                   Vector3D b,
                                   double epsilon)
Checks if the two vectors are element wise nearly equal. A small epsilon check is performed.
Pseudo code description:

result = false;
For index = 0 to 2 do
result &&= |vector1(index) - vector2(index)| < epsilon
endFor

Parameters:
a - The first vector.
b - The second vector.
epsilon - the maximum tolerated difference between the respective elements
Returns:
True if the two vectors are element wise nearly equal (see pseudo code). If one of the vectors is null, the function returns false.
See Also:
Vector3D.equals(Object)

elementEqual

public static boolean elementEqual(Matrix a,
                                   Matrix b,
                                   double epsilon)
Checks if the two matrices are element wise nearly equal. A small epsilon check is performed.
Pseudo code description:

result = false;
For row = 0 to 2 do
For column = 0 to 2 do
result &&= |matrix1(row,column) - matrix2(row,column)| < epsilon
endFor - column
endFor - row

Parameters:
a - The first matrix.
b - The second matrix.
epsilon - the maximum tolerated difference between the respective elements
Returns:
True if the two matrices are element wise nearly equal (see pseudo code). If one of the matrices is null, the function returns false.
See Also:
Matrix.equals(Object)

elementEqual

public static boolean elementEqual(Point3D a,
                                   Point3D b,
                                   double epsilon)
Checks if the two points are element wise nearly equal. A small epsilon check is performed.
Pseudo code description see elementEqual(Vector3D, Vector3D, double)

Parameters:
a - The first point.
b - The second point.
epsilon - the maximum tolerated difference between the respective elements
Returns:
True if the two points are element wise nearly equal. If one of the points is null, the function returns false.
See Also:
Point3D.equals(Object)

elementEqual

public static boolean elementEqual(IRotation a,
                                   IRotation b,
                                   double epsilon)
Checks if two Rotations are approximately equal by checking the matrix representations for element-wise approximate equality. A small epsilon check is performed.
Pseudo code description see elementEqual(Matrix, Matrix, double)

Parameters:
a - The first rotation.
b - The second rotation.
epsilon - the maximum tolerated difference between the respective matrix elements
Returns:
True if the matrix representations of the two rotations are approximately element-wise equal. If one of the rotations is null, the function returns false.

elementEqual

public static boolean elementEqual(ITransformation a,
                                   ITransformation b,
                                   double epsilon)
Checks if two transformations are approximately equal. Therefore the rotational part is handled as a Matrix and the translational part as a Vector. The rotational and the translational part of the transformations are compared element wise. (See elementEqual(Matrix, Matrix, double) and elementEqual(Vector3D, Vector3D, double) ). A small epsilon check is performed.

Parameters:
a - The first transformation.
b - The second transformation.
epsilon - the maximum tolerated difference between the respective matrix elements
Returns:
True if the matrix representations of the two transformation are approximately element-wise equal. If one of the transformations is null, the function returns false.

getDefaultNumberFormat

public static NumberFormat getDefaultNumberFormat()
Returns an instance of the default NumberFormat. The returned formatting is independent from your Locale settings.

Returns:
locale-independent representation of NumberFormat

defensiveCopy

public static IRotation defensiveCopy(IRotation orig)
Returns an immutable AbstractRotation instance of the given rotation. If the given rotation is already of a known immutable type then it is returned unchanged.

Parameters:
orig - The rotation whose value should be taken over.
Returns:
an immutable AbstractRotation instance
Throws:
IllegalArgumentException - if orig is null

defensiveCopy

public static ITransformation defensiveCopy(ITransformation orig)
Returns an immutable AbstractTransformation instance of the given transformation. If the given transformation is already of a known immutable type then it is returned unchanged.

Parameters:
orig - The transformation whose value should be taken over.
Returns:
an immutable AbstractTransformation instance
Throws:
IllegalArgumentException - if orig is null

getAxisVector

public static Vector3D getAxisVector(CoordinateAxis axis)
Returns an unit vector representing the specified CoordinateAxis.

Parameters:
axis - the axis of a Cartesian coordinate system
Returns:
unit vector Vector3D of the specified axis

getDirectionVector

public static Vector3D getDirectionVector(CoordinateDirection direction)
Returns an unit vector representing the specified CoordinateDirection.

Parameters:
direction - the direction along the axis of a Cartesian coordinate system
Returns:
unit vector Vector3D in the specified axis direction

getNormalVector

public static Vector3D getNormalVector(CoordinatePlane plane)
Returns the normal vector corresponding to the specified CoordinatePlane.

Parameters:
plane - the plane of a Cartesian coordinate system
Returns:
unit vector Vector3D that is perpendicular to the specified plane


Copyright © 2019. All rights reserved.