pythagoras.d

## Class GeometryUtil

• ```public class GeometryUtil
extends Object```
Various geometry utility methods.
• ### Field Summary

Fields
Modifier and Type Field and Description
`static double` `EPSILON`
• ### Constructor Summary

Constructors
Constructor and Description
`GeometryUtil()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```cubic(double t, double x1, double x2, double x3, double x4)```
`static int` ```intersectCubics(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double cx1, double cy1, double cx2, double cy2, double cx3, double cy3, double cx4, double cy4, double[] params)```
Checks whether two cubic curves (x1, y1) - (x2, y2) - (x3, y3) - (x4, y4) and (cx1, cy1) - (cx2, cy2) - (cx3, cy3) - (cx4, cy4) intersect.
`static int` ```intersectLineAndCubic(double x1, double y1, double x2, double y2, double cx1, double cy1, double cx2, double cy2, double cx3, double cy3, double cx4, double cy4, double[] params)```
Checks whether the line (x1, y1) - (x2, y2) and the cubic curve (cx1, cy1) - (cx2, cy2) - (cx3, cy3) - (cx4, cy4) intersect.
`static int` ```intersectLineAndQuad(double x1, double y1, double x2, double y2, double qx1, double qy1, double qx2, double qy2, double qx3, double qy3, double[] params)```
Checks whether there is intersection of the line (x1, y1) - (x2, y2) and the quad curve (qx1, qy1) - (qx2, qy2) - (qx3, qy3).
`static int` ```intersectLines(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double[] point)```
Checks whether line (x1, y1) - (x2, y2) and line (x3, y3) - (x4, y4) intersect.
`static int` ```intersectLinesWithParams(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double[] params)```
`static int` ```intersectQuadAndCubic(double qx1, double qy1, double qx2, double qy2, double qx3, double qy3, double cx1, double cy1, double cx2, double cy2, double cx3, double cy3, double cx4, double cy4, double[] params)```
Checks whether the quad (x1, y1) - (x2, y2) - (x3, y3) and the cubic (cx1, cy1) - (cx2, cy2) - (cx3, cy3) - (cx4, cy4) curves intersect.
`static int` ```intersectQuads(double x1, double y1, double x2, double y2, double x3, double y3, double qx1, double qy1, double qx2, double qy2, double qx3, double qy3, double[] params)```
Checks whether two quads (x1, y1) - (x2, y2) - (x3, y3) and (qx1, qy1) - (qx2, qy2) - (qx3, qy3) intersect.
`static double` ```line(double t, double x1, double x2)```
`static double` ```quad(double t, double x1, double x2, double x3)```
`static void` ```subCubic(double[] coef, double t0, boolean left)```
`static void` ```subQuad(double[] coef, double t0, boolean left)```
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### EPSILON

`public static final double EPSILON`
• ### Constructor Detail

• #### GeometryUtil

`public GeometryUtil()`
• ### Method Detail

• #### intersectLinesWithParams

```public static int intersectLinesWithParams(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4,
double[] params)```
• #### intersectLines

```public static int intersectLines(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4,
double[] point)```
Checks whether line (x1, y1) - (x2, y2) and line (x3, y3) - (x4, y4) intersect. If lines intersect then the result parameters are saved to point array. The size of `point` must be at least 2.
Returns:
1 if two lines intersect in the defined interval, otherwise 0.

```public static int intersectLineAndQuad(double x1,
double y1,
double x2,
double y2,
double qx1,
double qy1,
double qx2,
double qy2,
double qx3,
double qy3,
double[] params)```
Checks whether there is intersection of the line (x1, y1) - (x2, y2) and the quad curve (qx1, qy1) - (qx2, qy2) - (qx3, qy3). The parameters of the intersection area saved to `params`. Therefore `params` must be of length at least 4.
Returns:
the number of roots that lie in the defined interval.
• #### intersectLineAndCubic

```public static int intersectLineAndCubic(double x1,
double y1,
double x2,
double y2,
double cx1,
double cy1,
double cx2,
double cy2,
double cx3,
double cy3,
double cx4,
double cy4,
double[] params)```
Checks whether the line (x1, y1) - (x2, y2) and the cubic curve (cx1, cy1) - (cx2, cy2) - (cx3, cy3) - (cx4, cy4) intersect. The points of intersection are saved to `points`. Therefore `points` must be of length at least 6.
Returns:
the numbers of roots that lie in the defined interval.

```public static int intersectQuads(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double qx1,
double qy1,
double qx2,
double qy2,
double qx3,
double qy3,
double[] params)```
Checks whether two quads (x1, y1) - (x2, y2) - (x3, y3) and (qx1, qy1) - (qx2, qy2) - (qx3, qy3) intersect. The result is saved to `params`. Thus `params` must be of length at least 4.
Returns:
the number of roots that lie in the interval.

```public static int intersectQuadAndCubic(double qx1,
double qy1,
double qx2,
double qy2,
double qx3,
double qy3,
double cx1,
double cy1,
double cx2,
double cy2,
double cx3,
double cy3,
double cx4,
double cy4,
double[] params)```
Checks whether the quad (x1, y1) - (x2, y2) - (x3, y3) and the cubic (cx1, cy1) - (cx2, cy2) - (cx3, cy3) - (cx4, cy4) curves intersect. The points of the intersection are saved to `params`. Thus `params` must be of length at least 6.
Returns:
the number of intersection points that lie in the interval.
• #### intersectCubics

```public static int intersectCubics(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4,
double cx1,
double cy1,
double cx2,
double cy2,
double cx3,
double cy3,
double cx4,
double cy4,
double[] params)```
Checks whether two cubic curves (x1, y1) - (x2, y2) - (x3, y3) - (x4, y4) and (cx1, cy1) - (cx2, cy2) - (cx3, cy3) - (cx4, cy4) intersect. The result is saved to `params`. Thus `params` must be of length at least 6.
Returns:
the number of intersection points that lie in the interval.
• #### line

```public static double line(double t,
double x1,
double x2)```

```public static double quad(double t,
double x1,
double x2,
double x3)```
• #### cubic

```public static double cubic(double t,
double x1,
double x2,
double x3,
double x4)```
```public static void subQuad(double[] coef,
```public static void subCubic(double[] coef,