This class provides useful geometric primitives and advanced geometric algorithms.
Inheritance Hierarchy
Members
No filters for this type
Static Methods
static
Parameters
- 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.
Return Value
- boolean
- Whether the point lies within the ellipse
Calculates the convex hull for a set of points.
Calculates the convex hull for a set of points.
static
Parameters
- points: IEnumerable<Point>
- The given points for which the convex hull should be computed.
Return Value
- 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
xcoordinate. If two such points exist, then of these points, the one with the smallestycoordinate is chosen as the first one.
Complexity
O(n)*log(n), n := points.size()This will always return the intersection point that lies in the direction from inner to outer.
static
Parameters
- 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.
Return Value
- Point
- The intersection point iff the inner point lies inside the ellipse and an intersection point has been found, otherwise
null.
Each line is given by two points.
static
Parameters
- 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.
Return Value
- Point
- The intersection point of the specified lines or
nullif there is no intersection.
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))
}static
Parameters
- 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.
Return Value
- number
- The distance factor or Number.POSITIVE_INFINITY if the ray does not intersect the line.