This class provides useful geometric primitives and advanced geometric algorithms.
Inheritance Hierarchy
GeometryUtilities
Type Details
- yFiles module
- core
Static Methods
Returns whether the given points are collinear, that is, all three points lie on a common line.
Returns whether an ellipse contains the given point.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- bounds - Rect
- The coordinates of the bounds of the ellipse's enclosing rectangle.
- point - Point
- The coordinates of the point to test.
- eps - number
- A positive value allows for fuzzy hit testing. If the point lies outside the given object, but its distance is less than or equal to that value, it will be considered a hit.
Returns
- ↪boolean
- Whether the point lies within the ellipse
Calculates the convex hull for a set of points.
Complexity
O(n)*log(n), n := points.size()
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- points - IEnumerable<Point>
- The given points for which the convex hull should be computed.
Returns
- ↪IEnumerable<Point>
- A list of Points that constitute the convex hull of the given points. The returned points are in counterclockwise order around the hull. The first point is the one with the smallest
x
coordinate. If two such points exist, then of these points, the one with the smallesty
coordinate is chosen as the first one.
Calculates the intersection point of an ellipse with a line defined by two points.
Remarks
This will always return the intersection point that lies in the direction from inner to outer.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- bounds - Rect
- The coordinates of the bounds of the ellipse's enclosing rectangle.
- inner - Point
- The coordinates of a point lying inside the ellipse.
- outer - Point
- The coordinates of a point lying outside the ellipse.
Returns
- ↪Point?
- The intersection point iff the inner point lies inside the ellipse and an intersection point has been found, otherwise
null
.
Calculates the intersection point of two affine lines.
Remarks
Each line is given by two points.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- p1 - Point
- One point on the first line.
- p2 - Point
- Another point on the first line.
- p3 - Point
- One point on the second line.
- p4 - Point
- Another point on the second line.
Returns
- ↪Point?
- The intersection point of the specified lines or
null
if there is no intersection.
Calculates the intersection between a line segment and an infinite ray.
Remarks
The ray is described using an anchor point and a ray direction. The direction vector does not need to be normalized. To get the intersection point, do the following:
const factor = GeometryUtilities.getSegmentRayIntersection(
l1,
l2,
anchor,
ray,
)
if (factor < Number.POSITIVE_INFINITY) {
const intersection = anchor.add(ray.multiply(factor))
}
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- start - Point
- The coordinates of the first end point of the line segment.
- end - Point
- The coordinates of the second end point of the line segment.
- rayAnchor - Point
- The coordinates of the starting point of the ray.
- rayDirection - Point
- The direction vector of the ray.
Returns
- ↪number
- The distance factor or Number.POSITIVE_INFINITY if the ray does not intersect the line.
Returns whether the two lines defined by the given coordinates intersect or not.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- p1 - Point
- The first point of the first line.
- p2 - Point
- The second point of the first line.
- p3 - Point
- The first point of the second line.
- p4 - Point
- The second point of the second line.
Returns
- ↪boolean
true
if the two line segments intersect,false
otherwise