- Object
-
- RobustGeometry
-
public final class RobustGeometry extends Object
This class provides geometric routines that have guarantees about some properties of their floating point results and operations.- Since:
- 3.4.0
- Version:
- 3.4.0
- Author:
- Manolis Tsamis
-
-
Constructor Summary
Constructors Constructor Description RobustGeometry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AdaptiveDecimal
cross(double ax, double ay, double bx, double by)
Performs cross product on four primitives and also allocates a newAdaptiveDecimal
with the appropriate capacity to store the result.static AdaptiveDecimal
cross(double ax, double ay, double bx, double by, AdaptiveDecimal result)
Performs the cross product of two vectors a, b, that is ax * by - ay * bx but with extended precision and stores the 4 component result in the givenAdaptiveDecimal
result
.static double
getLocation(Vector2 point, Vector2 linePoint1, Vector2 linePoint2)
Robust side-of-line test.
-
-
-
Method Detail
-
cross
public static AdaptiveDecimal cross(double ax, double ay, double bx, double by)
Performs cross product on four primitives and also allocates a newAdaptiveDecimal
with the appropriate capacity to store the result.- Parameters:
ax
- The x value of the vector aay
- The y value of the vector abx
- The x value of the vector bby
- The y value of the vector b- Returns:
- The result
- See Also:
cross(double, double, double, double, AdaptiveDecimal)
-
cross
public static AdaptiveDecimal cross(double ax, double ay, double bx, double by, AdaptiveDecimal result)
Performs the cross product of two vectors a, b, that is ax * by - ay * bx but with extended precision and stores the 4 component result in the givenAdaptiveDecimal
result
. In the same way as withAdaptiveDecimal.sum(AdaptiveDecimal, AdaptiveDecimal)
ifresult
is null a new one is allocated, otherwise the existing is cleared and used.- Parameters:
ax
- The x value of the vector aay
- The y value of the vector abx
- The x value of the vector bby
- The y value of the vector bresult
- TheAdaptiveDecimal
in which the cross product is stored- Returns:
- The result
-
getLocation
public static double getLocation(Vector2 point, Vector2 linePoint1, Vector2 linePoint2)
Robust side-of-line test. Computes the same value withSegment.getLocation(Vector2, Vector2, Vector2)
but with enough precision so the sign of the result is correct for anyVector2
s pa, pb, pc. This implementation uses more precision as-needed only for the hardest cases. For the majority of inputs this will be only slightly slower than the corresponding call toSegment.getLocation(Vector2, Vector2, Vector2)
but in the hard cases can be 5-25 times slower.- Parameters:
point
- the pointlinePoint1
- the first point of the linelinePoint2
- the second point of the line- Returns:
- double
- See Also:
Segment.getLocation(Vector2, Vector2, Vector2)
-
-